Re: Reading GIF images in Win2k + Apache + PHP

From: Date: Tue, 18 Mar 2003 07:31:34 +0000
Subject: Re: Reading GIF images in Win2k + Apache + PHP
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-140077@lists.php.net to get a copy of this message
//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" <webdude@veslach.com> To: <php-general@lists.php.net> 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 >

« previous php.general (#140077) next »