//When converting an image from gif to jpeg or png, you need to create an intermediate image the same size as you want output. The following should work, but it's not tested. hope this helps, Hugh <?php $size=getimagesize($filename); // this will get the x & y dimensions and the file type (gif, jpeg, etc.) if ($size[2]==1) $orig_img = imagecreatefromgif($filename); if ($size[2]==2) $orig_img = imagecreatefromjpeg($filename); $destination_image=imagecreatetruecolor ( $size[0], $size[1]); // intermediate image the same size as orig_img imagecopy ( $destination_image, $orig_img, 0, 0, 0, 0, $size[0], $size[1]); header("content-type: image/jpeg"); // needed only if you want to use the data stream. imagejpeg($destination_image,'$new_file_name', 80); // if you just want the output, you can leave out the $new_file_name. imagedestroy($orig_img); imagedestroy($destination_image); ?>
----- Original Message ----- From: "Patrick Teague" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 17, 2003 10:47 PM Subject: [PHP] Reading GIF images in Win2k + Apache + PHP > I have a class that reads gif images & can then make jpeg or png thumbnails > of the gif image, but it only seems to work on linux. Is there any way to > open/convert the gif to some other graphic format so I can at least read the > gif image in on windows? > > here's the current code I have for reading in file types, but the gif > section blows up. Is there a way with something like readfile() or fopen() > to get the information from a gif file? > > switch($type) > { > case "gif": > $orig_img = imagecreatefromgif($filename); > break; > case "jpg": > $orig_img = imagecreatefromjpeg($filename); > break; > case "png": > $orig_img = imagecreatefrompng($filename); > break; > } > > Patrick > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php