$src_w){$dst_w=$src_w;} if($dst_h>$src_h){$dst_h=$src_h;} // Teste les dimensions tenant dans la zone $test_h = round(($dst_w / $src_w) * $src_h); $test_w = round(($dst_h / $src_h) * $src_w); // Si Height final non précisé (0) if(!$dst_h) $dst_h = $test_h; // Sinon si Width final non précisé (0) elseif(!$dst_w) $dst_w = $test_w; // Sinon teste quel redimensionnement tient dans la zone elseif($test_h>$dst_h) $dst_w = $test_w; else $dst_h = $test_h; // Content type if((substr($_GET['fichier_nom'],-3)=="jpg") or (substr($_GET['fichier_nom'],-3)=="JPG") or (substr($_GET['fichier_nom'],-4)=="jpeg")){ header('Content-type: image/jpeg'); } if((substr($_GET['fichier_nom'],-3)=="gif") or (substr($_GET['fichier_nom'],-3)=="GIF")){ header('Content-type: image/gif'); } if((substr($_GET['fichier_nom'],-3)=="png") or (substr($_GET['fichier_nom'],-3)=="PNG")){ header('Content-type: image/png'); } $image_p = imagecreatetruecolor($dst_w, $dst_h); // on met l'image de fond en blanc (pour les gif transparents) $white = imagecolorallocate($image_p, 255, 255, 255); imagefill($image_p,0,0,$white); // si jpg if((substr($_GET['fichier_nom'],-3)=="jpg") or (substr($_GET['fichier_nom'],-3)=="JPG") or (substr($_GET['fichier_nom'],-4)=="jpeg")){ $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w , $src_h ); imagejpeg($image_p,'',95); } // si gif if((substr($_GET['fichier_nom'],-3)=="gif") or (substr($_GET['fichier_nom'],-3)=="GIF")){ $image = imagecreatefromgif($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w , $src_h ); imagepng($image_p,'',5); } // si png if((substr($_GET['fichier_nom'],-3)=="png") or (substr($_GET['fichier_nom'],-3)=="PNG")){ $image = imagecreatefrompng($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w , $src_h ); imagepng($image_p,'',5); } //////////////////////////////////////////////////////////////////////////////// ?>