Open Hüfner's outside links in a new tab and crop the tree for the favicon
CMS quality / php (8.2) (push) Canceled after 0s
CMS quality / php (8.4) (push) Canceled after 0s
CMS quality / browser (push) Canceled after 0s
CMS quality / mysql (push) Canceled after 0s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kantarciandClaude Opus 5.5 committed 2026-10-12 14:03:03 +02:00
1 parent 69f7977ecf
commit 14e7a3b310
2 files changed
+37 -10

No files matched your search

+29 -6
View File
@@ -4,7 +4,7 @@
* Bereitet die Bilder des Hüfner-Entwurfs für die Mediathek vor.
*
* Kopiert die Fotos und das Logo aus dem gelieferten Ordner (images/) und schneidet aus dem Logo
* den Baum mit den Steinen als quadratisches Seitensymbol (favicon.png) heraus. Der Baum ist im
* den Baum (ohne die Steine) als quadratisches Seitensymbol (favicon.png) heraus. Der Baum ist im
* Logo links, der Schriftzug rechts; ein Favicon mit Schrift wäre in 32 px unlesbar.
*
* Aufruf: php scripts/build-huefner-assets.php <Quellordner mit images/> <Zielordner> [<Unterlagen>]
@@ -29,23 +29,46 @@ foreach (glob($quelle.'/images/*.{jpg,png}', GLOB_BRACE) ?: [] as $datei) {
copy($datei, $ziel.'/'.basename($datei));
}
// Baum und Steine: im 1600 x 607 px großen Logo etwa x 15–500, y 10–560.
// Nur der Baum: Krone (grün) und Stamm (dunkel) aus dem linken Teil des Logos, ohne die grauen
// Steine - die liefen bisher rechts aus dem Ausschnitt und sind in 32 px nur Rauschen (Umut,
// 12.10.2026: „schneide bitte den Baum zurecht“). Der Stamm ist dunkler als die Steine.
$logo = imagecreatefrompng($quelle.'/images/logo.png');
if (false === $logo) {
fwrite(STDERR, "logo.png lässt sich nicht lesen.\n");
exit(1);
}
$punkte = [];
[$bx0, $by0, $bx1, $by1] = [PHP_INT_MAX, PHP_INT_MAX, 0, 0];
for ($y = 10; $y < 520; ++$y) {
for ($x = 10; $x < 500; ++$x) {
$c = imagecolorat($logo, $x, $y);
if ((($c >> 24) & 127) > 100) {
continue;
}
[$r, $g, $b] = [($c >> 16) & 255, ($c >> 8) & 255, $c & 255];
if ($g > $r + 30 || ($r + $g + $b) / 3 < 70) {
$punkte[] = [$x, $y, $c];
[$bx0, $by0, $bx1, $by1] = [min($bx0, $x), min($by0, $y), max($bx1, $x), max($by1, $y)];
}
}
}
$baum = imagecreatetruecolor($bx1 - $bx0 + 1, $by1 - $by0 + 1);
imagesavealpha($baum, true);
imagealphablending($baum, false);
imagefill($baum, 0, 0, imagecolorallocatealpha($baum, 0, 0, 0, 127));
foreach ($punkte as [$x, $y, $c]) {
imagesetpixel($baum, $x - $bx0, $y - $by0, $c);
}
$kante = 512;
$symbol = imagecreatetruecolor($kante, $kante);
imagesavealpha($symbol, true);
imagealphablending($symbol, false);
imagefill($symbol, 0, 0, imagecolorallocatealpha($symbol, 0, 0, 0, 127));
imagealphablending($symbol, true);
[$x, $y, $b, $h] = [15, 10, 490, 550];
$massstab = min(($kante - 24) / $b, ($kante - 24) / $h);
[$b, $h] = [imagesx($baum), imagesy($baum)];
$massstab = min(($kante - 32) / $b, ($kante - 32) / $h);
$zb = (int) round($b * $massstab);
$zh = (int) round($h * $massstab);
imagecopyresampled($symbol, $logo, (int) (($kante - $zb) / 2), (int) (($kante - $zh) / 2), $x, $y, $zb, $zh, $b, $h);
imagecopyresampled($symbol, $baum, (int) (($kante - $zb) / 2), (int) (($kante - $zh) / 2), 0, 0, $zb, $zh, $b, $h);
imagepng($symbol, $ziel.'/favicon.png');
echo "Bilder kopiert, Seitensymbol geschnitten: $ziel\n";