46 if(extension_loaded(
'gd') && function_exists(
'imageCreateFromJpeg') && function_exists(
'imageCreateFromPng'))
49 $aTemp = explode(
".", $source);
50 $sMimeType = strtolower( array_pop($aTemp) );
53 list($original_x, $original_y) = getimagesize($source);
54 if ($original_x > $original_y)
57 $thumb_h = $original_y*($size/$original_x);
59 if ($original_x < $original_y)
61 $thumb_w = $original_x*($size/$original_y);
64 if ($original_x == $original_y)
70 $thumb_w = intval($thumb_w);
71 $thumb_h = intval($thumb_h);
79 $source = imageCreateFromJpeg($source);
80 $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
81 imagecopyresampled($dst_img,$source,0,0,0,0,$thumb_w,$thumb_h,$original_x,$original_y);
82 imagejpeg($dst_img, $destination, 90);
88 $source = imagecreatefrompng ($source);
89 $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
91 imagealphablending( $dst_img,
false );
92 imagesavealpha( $dst_img,
true );
94 imagecopyresampled($dst_img,$source,0,0,0,0,$thumb_w,$thumb_h,$original_x,$original_y);
95 imagepng($dst_img, $destination);
101 $source = imagecreatefromgif ($source);
102 $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
103 imagecopyresampled($dst_img,$source,0,0,0,0,$thumb_w,$thumb_h,$original_x,$original_y);
104 imagegif($dst_img, $destination);
112 imagedestroy($dst_img);
113 imagedestroy($source);