By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,949 Members | 1,455 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,949 IT Pros & Developers. It's quick & easy.

Workaround for "imagegif()"?

P: n/a
re: http://us4.php.net/manual/en/function.imagegif.php

I have one class method that resizes images, including GIF images, and
works just fine doing so, even up to this line:

[PHP]
eval('image' . $extArray[$type] . '($newImage, "$tmpImageDownloadDir/"
.. $this->fileName);'); // SAVE TO TEMPORARY IMAGE DIR FOR
DOWNLOAD
[/PHP]

(yes even with.. EVAL!)

However, in another class method, THIS line produces the following
error:

Fatal error: Call to undefined function: imagegif() in
/www/html/mu-spin/image_catalog/include/classes.inc.php(2262) :
eval()'d code on line 1
The line:

[PHP]
eval('image' . $extArray[$type] . '($newImage,
"$this->thumbLocationPath/$this->fileName", $thumbDimensionInt);');
[/PHP]

I've taken out the reference to $thumbDimensionInt, to no avail. Same
exact error every time, but ONLY for GIF images.

But why is it the nearly-identical line in one class method resizes
GIF images, but the near very same line in another class method
(creates thumbnails) bombs for GIF images?

Both work just fine for all other images (i.e., JPG, TIFF, PNG, SWF,
BMP, etc.)

Thanx
Phil
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 7 May 2004 15:21:39 -0700, so*****@erols.com (Phil Powell) wrote:
re: http://us4.php.net/manual/en/function.imagegif.php

I have one class method that resizes images, including GIF images, and
works just fine doing so, even up to this line:

[PHP]
eval('image' . $extArray[$type] . '($newImage, "$tmpImageDownloadDir/"
. $this->fileName);'); // SAVE TO TEMPORARY IMAGE DIR FOR
DOWNLOAD
[/PHP]

(yes even with.. EVAL!)

However, in another class method, THIS line produces the following
error:

>Fatal error: Call to undefined function: imagegif() in
/www/html/mu-spin/image_catalog/include/classes.inc.php(2262) :
eval()'d code on line 1

The line:

[PHP]
eval('image' . $extArray[$type] . '($newImage,
"$this->thumbLocationPath/$this->fileName", $thumbDimensionInt);');
[/PHP]

I've taken out the reference to $thumbDimensionInt, to no avail. Same
exact error every time, but ONLY for GIF images.

But why is it the nearly-identical line in one class method resizes
GIF images, but the near very same line in another class method
(creates thumbnails) bombs for GIF images?

Both work just fine for all other images (i.e., JPG, TIFF, PNG, SWF,
BMP, etc.)


Hm - you're _sure_ that the first one is actually calling imagegif? Unless
you're running a very old version of GD it shouldn't work, should give the
error you've posted. GIF support was removed ages ago because of the patent
restrictions surrounding the format (although read-only GIF support was patched
back in the version of GD bundled with recent PHPs).

Incidentally, wouldn't call_user_func be safer than eval? e.g.

<?php
$x = imagecreatefromgif('circle_1.gif');
$type = 'png';
header("Content-type: image/$type");
call_user_func("image$type", $x);
?>

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #2

P: n/a
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:eo********************************@4ax.com...
On 7 May 2004 15:21:39 -0700, so*****@erols.com (Phil Powell) wrote:
Hm - you're _sure_ that the first one is actually calling imagegif? Unless you're running a very old version of GD it shouldn't work, should give the
error you've posted. GIF support was removed ages ago because of the patent restrictions surrounding the format (although read-only GIF support was patched back in the version of GD bundled with recent PHPs).
The LZW patent expired last year. I wonder why they haven't yet restored GIF
support.
Incidentally, wouldn't call_user_func be safer than eval? e.g.

<?php
$x = imagecreatefromgif('circle_1.gif');
$type = 'png';
header("Content-type: image/$type");
call_user_func("image$type", $x);
?>


Personally I like to do this:

$imagecreatefrom_func = array(
1 => "imagecreatefromgif",
3 => "imagecreatefrompng",
2 => "imagecreatefromjpeg");

$image_func = array(
1 => "imagepng",
3 => "imagepng",
2 => "imagejpeg");

list($width, $height, $type, $attr) = getimagesize($filename);

if($f = @$imagecreatefrom_func[$type]) {
$g = $image_func[$type];
$img = $f($filename);
// do stuff with image
$g($img);
}

An elegant and flexible setup, methinks.
Jul 17 '05 #3

P: n/a
On Mon, 10 May 2004 19:44:41 -0400, "Chung Leong" <ch***********@hotmail.com>
wrote:
The LZW patent expired last year. I wonder why they haven't yet restored GIF
support.


It hasn't expired all round the world yet. That happens on July 7th 2004.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #4

P: n/a
"Chung Leong" <ch***********@hotmail.com> wrote in message news:<T4********************@comcast.com>...
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:eo********************************@4ax.com...
On 7 May 2004 15:21:39 -0700, so*****@erols.com (Phil Powell) wrote:
Hm - you're _sure_ that the first one is actually calling imagegif?

Unless
you're running a very old version of GD it shouldn't work, should give the
error you've posted. GIF support was removed ages ago because of the

patent
restrictions surrounding the format (although read-only GIF support was

patched
back in the version of GD bundled with recent PHPs).


The LZW patent expired last year. I wonder why they haven't yet restored GIF
support.
Incidentally, wouldn't call_user_func be safer than eval? e.g.

<?php
$x = imagecreatefromgif('circle_1.gif');
$type = 'png';
header("Content-type: image/$type");
call_user_func("image$type", $x);
?>


Personally I like to do this:

$imagecreatefrom_func = array(
1 => "imagecreatefromgif",
3 => "imagecreatefrompng",
2 => "imagecreatefromjpeg");

$image_func = array(
1 => "imagepng",
3 => "imagepng",
2 => "imagejpeg");

list($width, $height, $type, $attr) = getimagesize($filename);

if($f = @$imagecreatefrom_func[$type]) {
$g = $image_func[$type];
$img = $f($filename);
// do stuff with image
$g($img);
}

An elegant and flexible setup, methinks.

That's to an extent what I'm doing, however, "$g($img)" I was unaware
would work standalone. Because of the code structure I might fare
better with call_user_func, will give that a whirl.

Phil
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.