function create_thumbnail($source_img, $dest_img, $thumb_size) {
// redimensionnement d'une image, méthode douce (images lissées)
// ym_trainz 07/2010 - compilation des différents sources
// $source_img -> chemin de l'image source
// $dest_img -> chemin de la vignette à créer
// $thumb_size -> taille (largeur ou hauteur) de la vignette
// charger image et trouver la taille
$img = imagecreatefromjpeg($source_img); // pour les gif imagecreatefromgif et imagecreatefrompng,
$width = imagesx($img);
$height = imagesy($img);
// calcul taille thumbnail
if ($width > $height) {
$new_width = $thumb_size;
$new_height = floor( $height * ($thumb_size / $width));
}
else {
$new_height= $thumb_size;
$new_width = floor( $width * ($thumb_size / $height));
}
$dst = imagecreatetruecolor($new_width, $new_height);
$tmp_img = imagecreatetruecolor($width, $height);
// contourner le bug GD 2.0 (ignore 'source_x' et 'source_y'), passer par une autre image tmp
imagecopy ($tmp_img, $img,0,0,0,0, $width,$height);
imagecopyresampled($dst,$tmp_img,0,0,0,0,$new_width,$new_height,$width,$height);
imagejpeg($dst, $dest_img, 75);
imagedestroy($dst);
}