function makeThumb($filename, $filename_out, $width, $height, $quality, $thumbtype) {
# Informations sur l'image
list($width_orig,$height_orig,$type) = getimagesize($filename);
$padx = 0;
$pady = 0;
if ($width_orig > $height_orig) {
$y = $height_orig;
$x = $width * ( $y > $height ? $y/$height : $height/$y );
$padx = ($width_orig - $x) / 2;
}
if ($width_orig < $height_orig) {
$x = $width_orig;
$y = $height * ( $x > $width ? $x/$width : $width/$x );
$pady = ($height_orig - $y) / 2;
}
if ($width_orig == $height_orig) {
$x = $width_orig;
$y = $height_orig;
}
$image_p = imagecreatetruecolor($width,$height);
switch( $type ) {
case 2 : $image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, $padx, $pady, $width, $height, $x, $y );
imagejpeg( $image_p, $filename_out, $quality );
break;
case 1 : $image = imagecreatefromgif($filename);
imagesavealpha( $image_p, true );
$trans=imagecolorallocatealpha( $image_p, 255, 255, 255, 0 );
imagefill( $image_p, 0, 0, $trans );
imagecopy($image_p, $image, 0, 0, $padx, $pady, $width, $height);
imagegif( $image_p, $filename_out );
break;
case 3 : $image = imagecreatefrompng ( $filename );
imagesavealpha( $image_p, true );
$trans=imagecolorallocatealpha( $image_p, 255, 255, 255, 0 );
imagefill( $image_p, 0, 0, $trans );
imagecopyresampled($image_p, $image, 0, 0, $padx, $pady, $width, $height, $x, $y );
imagepng( $image_p, $filename_out );
break;
default : break;
}
}