次の関数を使用して画像のサムを作成していますが、何らかの理由で次の画像では機能しません: http://images.fanpop.com/images/image_uploads/zebra-zebras-52796_800_600.jpg
誰でも理由を理解できますか?
関数は次のとおりです。
function make_thumb($img_name,$filename,$new_w,$new_h)
{
//get image extension.
$ext=getExtension($img_name);
//create new image using the appropriate function from gd library
if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext) || !strcmp("JPEG",$ext) || !strcmp("JPG",$ext))
$src_img=imagecreatefromjpeg($img_name);
if(!strcmp("gif",$ext) || !strcmp("GIF",$ext))
$src_img=imagecreatefromgif($img_name);
if(!strcmp("png",$ext) || !strcmp("PNG",$ext))
$src_img=imagecreatefrompng($img_name);
//gets the dimmensions of the image
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
// calculate dimensions for the thumbnail
$ratio1=@$old_x/$new_w;
$ratio2=@$old_y/$new_h;
if($ratio1>$ratio2) {
$thumb_w=$new_w;
$thumb_h=$old_y/$ratio1;
}
else {
$thumb_h=$new_h;
$thumb_w=$old_x/$ratio2;
}
/**** start Customization *********************/
if($new_w > $old_x && $new_h > $old_y)
{
$thumb_w=$old_x;
$thumb_h=$old_y;
}
/**** end Customization *********************/
// create new image with the new dimensions
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
// resize
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
// output the created image to the file. Now we will have the thumbnail in the file named by $filename
if(!strcmp("png",$ext))
imagepng($dst_img,$filename);
elseif(!strcmp("gif",$ext))
imagegif($dst_img,$filename);
elseif(!strcmp("GIF",$ext))
imagegif($dst_img,$filename);
elseif(!strcmp("PNG",$ext))
imagegif($dst_img,$filename);
else
imagejpeg($dst_img,$filename);
//destroys source and destination images.
imagedestroy($dst_img);
imagedestroy($src_img);
}