Bildbasteln per gdlib

PHP:
<?php
 
header('Content-type: image/jpeg');
$file = 'witz.jpg';
$size        = getimagesize($file);
$width       = $size[0];
$height      = $size[1];
$old_picture = imagecreatefromjpeg($file);
$new_picture = imagecreatetruecolor($width, $height+100);
imagecopyresampled($new_picture, $old_picture, 0, 100, 0, 0, $width, $height, $width, $height);
// Verkleinerte Version soll oben drauf gesetzt weren das drauf setzen geht doch wie verkleinere ich das bild, dass es immer die höhe 100px hat und die Breite propertional zum orignal?
$transition          = 100;
$kleinesbildfile       = imagecreatefromjpeg('witz.jpg');
$kleinesbild_width  = 100;
$kleinesbild_height = 100;
$kleinesbilddest_x     = 0;
$kleinesbilddest_y     = 0;
imagecopymerge($new_picture, $kleinesbildfile, $kleinesbilddest_x, $kleinesbilddest_y, 0, 0, $kleinesbild_width, $kleinesbild_height, $transition);
imagejpeg($new_picture);
?>
kann mir einer helfen?
 
PHP:
<?php
header('Content-type: image/jpeg');
$file = 'witz.jpg';
$size        = getimagesize($file);
$width       = $size[0];
$height      = $size[1];
$old_picture = imagecreatefromjpeg($file);
$new_picture = imagecreatetruecolor($width, $height+100);
imagecopyresampled($new_picture, $old_picture, 0, 100, 0, 0, $width, $height, $width, $height);

$kleinesbild_height = 100;
// neue breite berechnen
$kleinesbild_width  = intval($width*$kleinesbild_height/$height);
// kleines bild erstellen
$kleinesbildfile    = imagecreatetruecolor($kleinesbild_width, $kleinesbild_height);
// bild verkleinern
imagecopyresampled($kleinesbildfile, $old_picture, 0, 0, 0, 0, $kleinesbild_width, $kleinesbild_height, $width, $height);

$transition         = 100;
$kleinesbilddest_x  = 0;
$kleinesbilddest_y  = 0;
imagecopymerge($new_picture, $kleinesbildfile, $kleinesbilddest_x, $kleinesbilddest_y, 0, 0, $kleinesbild_width, $kleinesbild_height, $transition);
imagejpeg($new_picture);
?>
 
Zurück
Oben