ca pourrait ptete te servir
function thumbnail($file, $maxWidth, $maxHeight)
{
echo "<br />".$maxWidth."x".$maxHeight."<br />";
$prod=$maxWidth*$maxHeight;
echo $prod."<br />";
//Créé une image à partir de $file
$img = ImageCreateFromJpeg("pics/$file");
//Dimensions de l'image
$imgWidth = imagesx($img);
$imgHeight = imagesy($img);
//Facteur largeur/hauteur des dimensions max
$whFact = $maxWidth/$maxHeight;
//Facteur largeur/hauteur de l'original
$imgWhFact = $imgWidth/$imgHeight;
//fixe les dimensions du thumb
if($imgWidth > $imgHeight)
{
//Si largeur déterminante
$thumbWidth = $maxWidth;
$thumbHeight = $thumbWidth/$imgWhFact;
}
else
{
//Si hauteur déterminante
$thumbHeight = $maxHeight;
$thumbWidth = $thumbHeight*$imgWhFact;
}
echo "<br />".$thumbWidth."x".$thumbHeight."<br />";
//Créé le thumb (image réduite)
$imgThumb = ImageCreateTruecolor($thumbWidth, $thumbHeight);
//Insère l'image de base redimensionnée
ImageCopyResampled($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight);
//Nom du fichier thumb
$imgThumbName = "pics/small/".$file;
//Créé le fichier thumb
$fp = fopen($imgThumbName, "w");
fclose($fp);
//Renvoie le thumb créé
ImageJpeg($imgThumb, $imgThumbName, 90);
return $imgThumbName;
}