note 43637 added to function.imagecreatefromgif
| From: | Randolpho at rn2 dot php dot net | Date: | Mon, 28 Jun 2004 22:02:12 +0000 |
| Subject: | note 43637 added to function.imagecreatefromgif | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-72075@lists.php.net to get a copy of this message | ||
Ok, here's an interesting tidbit. I wouldn't call it a bug, exactly, but it did make for
an interesting workaround the GD/GIF situation.
using PHP Version 4.3.4/GD bundled (2.0.15 compatible), I am able to use imagecreatefromgif() to
load an image into GD, although I am not able to use imagegif() to display it.
I'm not sure *why* this is, but the practical aspect is that if you need to do dynamic changes
to a loaded image and want to display it to the browser (for example, a dynamic thumbnailer), you
can load a gif image using imagecreatefromgif(), and then display it using a different image type! I
recommend using PNG, since JPG is a lossy format.
For example, given some image at $location:
<?php
$test = strtolower($location);
if(strpos($test, ".jpg") !== false || strpos($test, ".jpeg") !== false)
{
$this->OriginalImage = imagecreatefromjpeg($location);
$ImageType = "jpg";
header("Content-type: image/jpeg");
}
// transform GIFs into PNGs
else if(strpos($test, ".gif") !== false)
{
$OriginalImage = imagecreatefromgif($location);
$ImageType = "png";
header("Content-type: image/png");
}
else if(strpos($test, ".png") !== false)
{
$OriginalImage = imagecreatefrompng($location);
$ImageType = "png";
header("Content-type: image/png");
}
/*
*
* Do some image manipulation, stored for this example as $OutputImage
*
*/
switch ($ImageType)
{
case "jpg":
imagejpeg($OutputImage);
break;
case "png":
imagepng($OutputImage);
break;
default:
break;
}
?>
Now, as I said, I'm not sure if this is an oversight/bug or not, but if you can get it working,
it's a great workaround for GD's lack of GIF processing.
----
Manual Page -- http://www.php.net/manual/en/function.imagecreatefromgif.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43637
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43637&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43637&report=yes
Search -- http://master.php.net/manage/user-notes.php