Instagram-Grid auf natives Portrait-Format 4:5 (1080x1350) umgestellt — Crop auf 640x800 statt Quadrat

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 21:29:36 +02:00
parent 181f52fc73
commit fc066703e6
3 changed files with 14 additions and 6 deletions

View File

@@ -146,7 +146,7 @@ if ($posts === []) {
$fail('Keine Posts ermittelbar (Instagram blockt vermutlich die Server-IP oder hat die Struktur geändert)');
}
// --- Bilder lokal laden, auf 640px-Quadrat bringen ---
// --- Bilder lokal laden, auf Instagram-Portrait 4:5 (640x800) bringen ---
if (!is_dir($imgDir)) {
mkdir($imgDir, 0755, true);
}
@@ -167,9 +167,16 @@ foreach ($posts as $post) {
}
$w = imagesx($src);
$h = imagesy($src);
$side = min($w, $h);
$out = imagecreatetruecolor(640, 640);
imagecopyresampled($out, $src, 0, 0, (int) (($w - $side) / 2), (int) (($h - $side) / 2), 640, 640, $side, $side);
// Mittiger Crop auf 4:5 (Instagram-Portrait), dann auf 640x800 skalieren.
if ($w / $h > 4 / 5) {
$cropH = $h;
$cropW = (int) round($h * 4 / 5);
} else {
$cropW = $w;
$cropH = (int) round($w * 5 / 4);
}
$out = imagecreatetruecolor(640, 800);
imagecopyresampled($out, $src, 0, 0, (int) (($w - $cropW) / 2), (int) (($h - $cropH) / 2), 640, 800, $cropW, $cropH);
imagejpeg($out, $file, 80);
}