Re: Convert GIF to JPG with or without GD
| From: | Daniel Ward | Date: | Thu, 07 Aug 2003 04:49:44 +0000 |
| Subject: | Re: Convert GIF to JPG with or without GD | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158603@lists.php.net to get a copy of this message | ||
The following code works on Win2K, Apache 1.3.27, PHP 4.3.2
$gif = imagecreatefromgif('image.gif');
$w = imagesx($gif);
$h = imagesy($gif);
$jpg = imagecreate($w, $h);
// or $jpg = imagecreatetruecolor($w, $h); but colors are off
imagecopy($pic, $im, 0, 0, 0, 0, $w, $h);
// or imagecopyresampled($jpg, $gif, 0, 0, 0, 0, $w, $h, $w, $h);
imagejpeg($jpg); // also works with imagepng()
imagedestroy($gif);
imagedestroy($jpg);
exit;
don't have 4.3 on my linux box yet so I haven't tested it there