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
| <?php
mkdir("photos");
// La miniature :
// Le fichier
$filename = $_FILES['Filedata']['tmp_name'];
// Définition de la largeur et de la hauteur maximale
$width = 350;
$height = 350;
// 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
$image_finale=imagejpeg($image_p, "photos/".$_POST['nom'].".jpg", 100);
?> |
Partager