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
   | <?php
// Le fichier
$filename = 'PHOTOS/'.$fichier;
 
// Définition de la largeur et de la hauteur maximale
$width = 200;
$height = 200;
 
// Content type
header('Content-type: image/jpeg');
 
// Cacul des nouvelles dimensions
list($width_orig, $height_orig) = getimagesize($filename);
 
$ratio_orig = $width_orig/$height_orig;
 
if ($width/$height > $ratio_orig) {
   $width = $height*$ratio_orig;
} else {
   $height = $width/$ratio_orig;
}
 
// Redimensionnement
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
 
// Affichage
imagejpeg($image_p, null, 100);
?> | 
Partager