Citation :
if ($type=="jpg" )
{
Header("Content-type: image/jpeg" );
$src_im = imagecreatefromjpeg($image);
}
else if ($type=="gif" )
{
header("Content-Type: image/gif" );
$src_im = imagecreatefromgif($image);
}
else if ($type=="png" )
{
header("Content-Type: image/png" );
$src_im = imagecreatefrompng($image);
}
$size = getimagesize($image);
$src_w = $size[0];
$src_h = $size[1];
//taille de votre image
$dst_w = $taille;
// Contraint le rééchantillonage à une largeur fixe
// Maintient le ratio de l'image
$dst_h = round(($dst_w / $src_w) * $src_h);
$dst_im = imagecreatetruecolor($dst_w,$dst_h);
imagecopyresampled($dst_im,$src_im,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
if ($type=="jpg" )imagejpeg($dst_im, null, 100);
else if ($type=="gif" ) imagegif($dst_im, null);
else if ($type=="png" )imagepng($dst_im, null);
imagedestroy($dst_im);
imagedestroy($src_im);
|