Files
KantSites/scripts/build-kantarci-reisen-assets.php
kantarciandClaude Opus 5.5 c7705b7083 Add the Kantarci Reisen build scripts and local launch configurations
Seed, reset and asset scripts for the tenth installation, plus dev and prod launch entries
for it and for the multilingual test copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 16:56:44 +02:00

89 lines
3.6 KiB
PHP

<?php
/**
* Bereitet die Bilder des Kantarci-Reisen-Entwurfs für die Mediathek vor.
*
* Aus dem gelieferten Paket (Website/ und Logo/) entstehen:
* - logo.png: das Logo ohne den breiten durchsichtigen Rand (im Original rund ein Viertel der Fläche),
* - favicon.png: das „K“ mit Sonne und Schwingen als quadratisches Seitensymbol,
* - kueste.webp: das Reisefoto der Vorlage, unverändert,
* - reisesoft-uebersicht.png: der Screenshot der reiseSoft-Übersicht, falls als zweites Argument
* angegeben (aufgenommen aus einer lokalen Instanz mit den fiktiven Demodaten von reiseSoft).
*
* Aufruf: php scripts/build-kantarci-reisen-assets.php <Paketordner Kantarci-Reisen> <Zielordner> [Screenshot]
*/
$quelle = rtrim($argv[1] ?? '', '/\\');
$ziel = rtrim($argv[2] ?? '', '/\\');
$screenshot = $argv[3] ?? '';
if ('' === $quelle || '' === $ziel || !is_file($quelle.'/Website/coast.webp')) {
fwrite(STDERR, "Aufruf: php scripts/build-kantarci-reisen-assets.php <Ordner Kantarci-Reisen> <Zielordner> [Screenshot]\n");
exit(1);
}
if (!is_dir($ziel) && !mkdir($ziel, 0775, true)) {
fwrite(STDERR, "Zielordner lässt sich nicht anlegen: $ziel\n");
exit(1);
}
copy($quelle.'/Website/coast.webp', $ziel.'/kueste.webp');
if ('' !== $screenshot) {
copy($screenshot, $ziel.'/reisesoft-uebersicht.png');
}
$logo = imagecreatefrompng($quelle.'/Logo/kantarci-reisen-logo-original.png');
if (false === $logo) {
fwrite(STDERR, "Das Logo lässt sich nicht lesen.\n");
exit(1);
}
$breite = imagesx($logo);
$hoehe = imagesy($logo);
/** Kleinstes Rechteck um alle sichtbaren Pixel (Deckkraft über 10 %) innerhalb eines Bereichs. */
$rahmen = static function (int $x0, int $y0, int $x1, int $y1) use ($logo): array {
[$links, $oben, $rechts, $unten] = [$x1, $y1, $x0, $y0];
for ($y = $y0; $y < $y1; $y += 2) {
for ($x = $x0; $x < $x1; $x += 2) {
if ((imagecolorat($logo, $x, $y) >> 24 & 0x7F) < 115) {
$links = min($links, $x);
$rechts = max($rechts, $x);
$oben = min($oben, $y);
$unten = max($unten, $y);
}
}
}
return [$links, $oben, $rechts - $links + 1, $unten - $oben + 1];
};
$neu = static function (int $b, int $h) {
$bild = imagecreatetruecolor($b, $h);
imagesavealpha($bild, true);
imagealphablending($bild, false);
imagefill($bild, 0, 0, imagecolorallocatealpha($bild, 0, 0, 0, 127));
imagealphablending($bild, true);
return $bild;
};
// Ganzes Logo mit 12 px Luft.
[$x, $y, $b, $h] = $rahmen(0, 0, $breite, $hoehe);
$rand = 12;
$zuschnitt = $neu($b + 2 * $rand, $h + 2 * $rand);
imagecopy($zuschnitt, $logo, $rand, $rand, $x, $y, $b, $h);
imagepng($zuschnitt, $ziel.'/logo.png');
// Das Bildzeichen steht links bis etwa 38 % der Breite. Die obere Schwinge reicht dabei über den
// Anfang des Schriftzugs; das „K“ von KANTARCI beginnt erst unterhalb von ihr (ab etwa 35,5 % der
// Breite und 40 % der Höhe). Diese Ecke wird vor dem Zuschnitt geleert.
imagealphablending($logo, false);
imagefilledrectangle($logo, (int) ($breite * 0.355), (int) ($hoehe * 0.40), $breite - 1, $hoehe - 1, imagecolorallocatealpha($logo, 0, 0, 0, 127));
[$x, $y, $b, $h] = $rahmen(0, 0, (int) ($breite * 0.40), $hoehe);
$kante = 512;
$symbol = $neu($kante, $kante);
$massstab = min(($kante - 40) / $b, ($kante - 40) / $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 vorbereitet: $ziel\n";