php5 upgrade - imagecreatefromgif no longer working?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
redherring
Forum Newbie
Posts: 6
Joined: Fri Jan 25, 2008 8:52 pm

php5 upgrade - imagecreatefromgif no longer working?

Post 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!
redherring
Forum Newbie
Posts: 6
Joined: Fri Jan 25, 2008 8:52 pm

Re: php5 upgrade - imagecreatefromgif no longer working?

Post 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.
redherring
Forum Newbie
Posts: 6
Joined: Fri Jan 25, 2008 8:52 pm

Re: php5 upgrade - imagecreatefromgif no longer working?

Post 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);
?>
 
Last edited by Weirdan on Sat Jan 26, 2008 4:35 am, edited 2 times in total.
Reason: php tags
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: php5 upgrade - imagecreatefromgif no longer working?

Post 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().
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: php5 upgrade - imagecreatefromgif no longer working?

Post by Chris Corbyn »

~redherring, please put

Code: Select all

 and [/php ] tags around your code so our board highlights it ;)
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Re: php5 upgrade - imagecreatefromgif no longer working?

Post 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]
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: php5 upgrade - imagecreatefromgif no longer working?

Post 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.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Re: php5 upgrade - imagecreatefromgif no longer working?

Post 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...
Post Reply