*/
$quelle = rtrim($argv[1] ?? '', '/\\');
$ziel = rtrim($argv[2] ?? '', '/\\');
if ('' === $quelle || '' === $ziel || !is_dir($quelle.'/images')) {
fwrite(STDERR, "Aufruf: php scripts/build-huefner-assets.php \n");
exit(1);
}
if (!is_dir($ziel) && !mkdir($ziel, 0775, true)) {
fwrite(STDERR, "Zielordner lässt sich nicht anlegen: $ziel\n");
exit(1);
}
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.
$logo = imagecreatefrompng($quelle.'/images/logo.png');
if (false === $logo) {
fwrite(STDERR, "logo.png lässt sich nicht lesen.\n");
exit(1);
}
$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);
$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);
imagepng($symbol, $ziel.'/favicon.png');
echo "Bilder kopiert, Seitensymbol geschnitten: $ziel\n";