Hi,
I wonder if anyone can shed some light on what's wrong with my code.
The problem is that I don't know whether or not $the_image is going to be a gif or jpeg. I tried to put some extra code in to get it to detect which type the image was (show below) but this hasn't seemed to work.
If I specify a jpeg for $the_image it outputs the image fine but if I specify a gif the output is just a black block.
Here is the code:
<?php
$the_image = "/path/to/image";
$image_info = GetImageSize($the_image);
if ($image_info[2] == 1) { Header("Content-Type: image/gif"); }
elseif ($image_info[2] == 2) { Header("Content-Type: image/jpeg"); }
$fp_x = $image_info[0] / 1.3; // fp_x is new image width
$fp_y = $image_info[1] / 1.3; // fp_y is new image height
$dst_img=ImageCreateTrueColor($fp_x - 1,$fp_y - 1);
if ($image_info[2] == 1) { $src_img=ImageCreateFromGif($the_image); }
elseif ($image_info[2] == 2) { $src_img=ImageCreateFromJpeg($the_image); }
ImageCopyResampled($dst_img,$src_img,0,0,0,0,$fp_x,$fp_y,ImageSX($src_img),ImageSY($src_img));
if ($image_info[2] == 1) { ImageGif($dst_img); }
elseif ($image_info[2] == 2) { ImageJpeg($dst_img,'',95); }
ImageDestroy($src_img);
ImageDestroy($dst_img);
?>
Any ideas?
Thanks in advance,
- Toast