1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| //header('Content-Type: image/jpeg');
$source = imagecreatefromstring($photo['image']);
$width_src = imagesx($source);
echo '<br>';
echo $width_src;
$height_src = imagesy($source);
echo '<br>';
echo $height_src;
if ($width && ($width_src < $height_src)) {
$width = ($height / $height_src) * $width_src;
} else {
$height = ($width / $width_src) * $height_src;
}
$ext = 'image/jpeg';
$destination = imagecreatetruecolor ($width_src, $height_src) or die ("Erreur pour créer l'image");
// on créé un cadre autour de la miniature
$blanc = imagecolorallocate ($destination, 255, 255, 255);
$gris[0] = imagecolorallocate ($destination, 69, 69, 69);
$gris[1] = imagecolorallocate ($destination, 82, 82, 82);
$gris[2] = imagecolorallocate ($destination, 97, 97, 97);
$gris[3] = imagecolorallocate ($destination, 107, 107, 107);
$gris[4] = imagecolorallocate ($destination, 120, 120, 120);
$gris[5] = imagecolorallocate ($destination, 134, 134, 134);
$gris[6] = imagecolorallocate ($destination, 145, 145, 145);
for ($i=0; $i<7; $i++) {
imagefilledrectangle($destination, $i, $i, $width-$i, $height-$i, $gris[$i]);
}
// créé la miniature : attention fonction lourde
imagecopyresampled($destination, $source, 8, 8, 0, 0, $width_src, $height_src, $width_src, $height_src);
//call_user_func('image.jpg', $destination);
imagejpeg($source);
imagedestroy($source);
imagedestroy($destination); |
Partager