Page 1 of 1

php5 upgrade - imagecreatefromgif no longer working?

Posted: Fri Jan 25, 2008 8:57 pm
by redherring
Hi there -

I was forced into an "upgrade" from php 4.3.8 to 5.2.5 today.

We have a bunch of pages that employ the imagecreatefromgif function, and none of these are working since the move to php5.

These page, highly dumbed down, are all as follows:

Code: Select all

 
<?php
header ("Content-type: image/png");
 
$im = imagecreatefromgif("http://www.mydomain.com/images/myimage.gif");
 
imagepng ($im);
?>
 
When called, the pages simply render a broken image of property "myimage.gif".

I can confirm that the image "http://www.mydomain.com/images/myimage.gif" exists.

There must be something fundamental missing from my php5 installation. Here's hoping that somebody can point me in the right direction.

Thanks!

Re: php5 upgrade - imagecreatefromgif no longer working?

Posted: Fri Jan 25, 2008 9:17 pm
by redherring
Sorry... assuming that the page is called "testimage.php", when browsed to the page simply renders a broken image of property "testimage.php" (to be accurate).

Thanks again in advance.

Re: php5 upgrade - imagecreatefromgif no longer working?

Posted: Fri Jan 25, 2008 9:32 pm
by redherring
And the following test, taken from elsewhere, also just renders a broken image:

Code: Select all

 
<?php
function LoadGif ($imgname)
{
    $im = @imagecreatefromgif ($imgname); /* Attempt to open */
    if (!$im) { /* See if it failed */
        $im = imagecreatetruecolor (150, 30); /* Create a blank image */
        $bgc = imagecolorallocate ($im, 255, 255, 255);
        $tc = imagecolorallocate ($im, 0, 0, 0);
        imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
        /* Output an errmsg */
        imagestring ($im, 1, 5, 5, "Error loading $imgname", $tc);
    }
    return $im;
}
header("Content-Type: image/gif");
$img = LoadGif("bogus.image");
imagegif($img);
?>
 

Re: php5 upgrade - imagecreatefromgif no longer working?

Posted: Sat Jan 26, 2008 3:48 am
by onion2k
By the sound of things your version of the GD library is a little out of date. Back on version 1.6 GIF was supported, but then there were patent issues so it was removed for GD2.0. It came back in version 2.0.28 (ish) when Unisys' patent ran out. If you're running a version of GD between 2.0 and 2.0.28 any gif functions won't work ... that's imagecreatefromgif() and imagegif().

Re: php5 upgrade - imagecreatefromgif no longer working?

Posted: Sat Jan 26, 2008 4:03 am
by Chris Corbyn
~redherring, please put

Code: Select all

 and [/php ] tags around your code so our board highlights it ;)

Re: php5 upgrade - imagecreatefromgif no longer working?

Posted: Sat Jan 26, 2008 4:28 am
by JAM
Also, remove the @ before function(s) and //comment any lines regarding the header() function. On top of that, add error_reporting("E_ALL"); at the top.
This makes it more possible to see any error messages that the server sends you. Perhaps not in this case as imagefunctions are cra p to debug, but just a thought of things to do at all times...

Also, the

Code: Select all

is broken in certain aspects,

Code: Select all

is not. [/size]

Re: php5 upgrade - imagecreatefromgif no longer working?

Posted: Sat Jan 26, 2008 4:36 am
by Weirdan
JAM wrote:Also, the

Code: Select all

is broken in certain aspects,

Code: Select all

is not. [/size][/quote]
To me they look absolutely identical.

Re: php5 upgrade - imagecreatefromgif no longer working?

Posted: Sat Jan 26, 2008 4:45 am
by JAM
Weirdan wrote:
JAM wrote:Also, the

Code: Select all

is broken in certain aspects,

Code: Select all

is not. [/size][/quote]
To me they look absolutely identical.[/quote]
Off topic, but I noticed problems when trying to edit my own post in another thread. The ;) in was changed into a smilie when using

Code: Select all

. Might just have been a wierd one-thing issue tho...