Web Hosting Talk







View Full Version : PHP Imaging w/ GIFs


Falco1199
01-25-2003, 12:10 AM
I just made an random image producing script, here's the code:

<?php

Header("Content-Type: image/jpeg");

mt_srand((double) microtime() * 1000000);
$rand = mt_rand(1,2);
$randImage = "Image" . $rand . ".jpg";

$image = ImageCreateFromJPEG($randImage);
ImageJPEG($image);

?>

And that worked fine. Then, I tried doing it in a GIF format (I saved the images as GIFs as well), with this script:

<?php

Header("Content-Type: image/gif");

mt_srand((double) microtime() * 1000000);
$rand = mt_rand(1,2);
$randImage = "FalcGIF" . $rand . ".gif";

$image = ImageCreateFromGIF($randImage);
ImageGIF($image);

?>

But it gave me this error:

<br>
<b>Warning</b>: ImageCreateFromGif: No GIF read support in this PHP build in <b>/path/Media/Images/RandImageGIFStyle.php</b> on line <b>9</b><br>
<br>
<b>Warning</b>: ImageGif: No GIF create support in this PHP build in <b>/path/Media/Images/RandImageGIFStyle.php</b> on line <b>10</b><br>

Is that a PHP configuration thing? It seems really weird.

VH-Robert
01-25-2003, 12:18 AM
Seems like it can't handle the creation of GIF images, just JPEG images.

Falco1199
01-25-2003, 12:31 AM
That's what I was thinking. A friend of mine got the same problem on his server with the same script (he was testing it for me). So maybe this is common among servers?

inverus
01-25-2003, 12:44 AM
GD doesn't have built in gif support any more.. ever since the ppl who developed the gif compression started suing everyone. Try the PNG format as a replacement.

Rich2k
01-25-2003, 07:11 AM
That is correct, you need a license to create .gif images now (i.e. you and I don't pay but the guys who write the software do).

inverus
01-25-2003, 12:43 PM
http://burnallgifs.org/

rigor
01-25-2003, 01:34 PM
if you dig around you can find some gif gd code but you will have to recompile gd/php/etc. If you look hard enough you'll find what you need.. of course USING such code is illegal without license.
:rolleyes:

inverus
01-25-2003, 02:32 PM
I wouldn't bother unless it's important. firstly, the PNG format is pretty darn good =D secondly, php 4.3.0+ has GD packaged into it (easier to install). No gif support there.

Rich2k
01-25-2003, 04:41 PM
You get extra functions if you use the built in GD as well

DeX
01-28-2003, 06:33 PM
Dont worry about useing .PNG it is widely supported by browsers now and even better than .GIF in most ways - can handle more than 256 colors, have better compression. Only con is that it cannot handle animations.

Alex042
10-10-2003, 08:15 AM
That is correct, you need a license to create .gif images now (you and I don't pay but the guys who write the software do).
Ugh, no wonder this script doesn't work. I thought my GD library was corrupted until I noticed something on php.net regarding this. I was hoping there might be some support for this by now. I doubt if someone providing a free script could afford to purchase any kind of licensing so this support would likely have to come from somewhere else. Now it looks like it won't be supported until the patent expires on July 7, 2004? :eek:

atr
10-10-2003, 09:45 AM
Originally posted by rigor
if you dig around you can find some gif gd code but you will have to recompile gd/php/etc. If you look hard enough you'll find what you need.. of course USING such code is illegal without license.
:rolleyes:

Originally posted by rich2k
That is correct, you need a license to create .gif images now (i.e. you and I don't pay but the guys who write the software do).

From the GD Library FAQ:

Many have asked whether gd will support creating GIF files again, since we have passed June 20th, 2003, when the well-known Unisys LZW patent expired in the US. Although this patent has expired in the United States, this patent does not expire for another year in the rest of the world. Since I have no way of limiting distribution of GIF-creating code to US users only that is guaranteed to please somebody else's lawyer, I have opted to follow the same policy that the ImageMagick authors are following: GIF creation will not reappear in gd until the patent expires world-wide on July 7th, 2004.

I recently had my version of GD patched to support gif creation. You can get a patch here:

http://www.rime.com.au/gd/

Notice that there is no patent covering LZW (gifs) in Australia. That means if you're in the US or Australia, there's nothing illegal or patent-infringing about this.

Older versions (pre-1.6) of GD also support gif creation.

But, yeah, in most cases PNG files are adequate and often they are superior.

Rich2k
10-10-2003, 02:02 PM
Err yes, but if you look at the post date of when this was brought up the patent was still in force and PHP hadn't updated the inbuilt GD to allow GIF creation again.

I believe that in the US the patent has expired but in the UK it hasn't? Not sure, just remember reading it somewhere.

atr
10-10-2003, 02:20 PM
Originally posted by Rich2k
Err yes, but if you look at the post date of when this was brought up the patent was still in force and PHP hadn't updated the inbuilt GD to allow GIF creation again.

I believe that in the US the patent has expired but in the UK it hasn't? Not sure, just remember reading it somewhere.

You're right. My apologies.

Alex042
10-10-2003, 02:37 PM
I believe that in the US the patent has expired but in the UK it hasn't?
Does that mean a US based company can install this on their servers?

Rich2k
10-10-2003, 04:10 PM
Dodgy, best wait until the patent expires completely.

However I don't actually know it's just something I kind of remember reading a few months back.

atr
10-10-2003, 07:10 PM
Originally posted by Alex042
Does that mean a US based company can install this on their servers?

Yes, it does--if the server is in the US.

http://www.boutell.com/gd/faq.html

http://www.rime.com.au/gd/