$max_h) $max_w = $test_w; else $max_h = $test_h; // Affiche les dimensions optimales $final_h = $max_h; $final_w = $max_w; $ext = strtolower(trim(substr($img_path,strrpos($img_path,'.')+1,4))); $img_dst = @ImageCreateTrueColor($final_w,$final_h); if($ext=="jpg") $img_src = ImageCreateFromJpeg($img_path); elseif($ext=="gif") { $black = imagecolorallocate($img_dst, 0, 0, 0); imagecolortransparent($img_dst, $black); $img_src = ImageCreateFromGif($img_path); } elseif($ext=="png") $img_src = ImageCreateFromPng($img_path); $src_w = imagesx($img_src); $src_h = imagesy($img_src); ImageCopyResampled($img_dst,$img_src,0,0,0,0,$final_w,$final_h,$src_w,$src_h); if($ext=="jpg") ImageJpeg($img_dst,str_replace('-orig.','-'.$max.'.',$img_path),100); elseif($ext=="gif") ImageGif($img_dst,str_replace('-orig.','-'.$max.'.',$img_path),100); elseif($ext=="png") ImagePng($img_dst,str_replace('-orig.','-'.$max.'.',$img_path),9); imagedestroy($img_dst); ?>