Web Hosting Talk







View Full Version : PHP & GD Library


jmillsy
01-21-2005, 12:40 PM
Hello Everyone,

Im looking to convert a JPEG Image to a GIF image.

This very easily done.. however, there is a small issue.

My GD library is installed, and support for all (most, rather) image formats are enabled. Here's my gd_info() array:
array(11) {
["GD Version"]=>
string(27) "bundled (2.0.12 compatible)"
["FreeType Support"]=>
bool(true)
["FreeType Linkage"]=>
string(13) "with freetype"
["T1Lib Support"]=>
bool(false)
["GIF Read Support"]=>
bool(true)
["GIF Create Support"]=>
bool(false)
["JPG Support"]=>
bool(true)
["PNG Support"]=>
bool(true)
["WBMP Support"]=>
bool(true)
["XBM Support"]=>
bool(true)
["JIS-mapped Japanese Font Support"]=>
bool(false)
}

If you notice, everything up GIF Create Support is enabled. Meaning, I can't create a GIF. (Just incase you didnt figure that out ;))

Anyway, my question is: How the heck can I <i>enable</i> the GIF Image Create Support? I can't find anything online anywhere. And it doesnt help that I am running Plesk, and they move files around.

Any help is appreciated!
John

error404
01-21-2005, 01:19 PM
You'll need to rebuild GD and then the PHP GD module (may not be necessary if it was dynamically linked) with GIF support. It was removed from the library for years due to patent issues, but now has been included again.

You can find the library at http://www.boutell.com/gd/ , if you install from source, make sure you install it to /usr so that it overwrites the old version. Or, preferably, build a package for your distribution and install that. If you need to rebuild PHP, you should be able to just run the source package building command on your distribution to do this.

But really, just use PNG. It's better in every respect :rolleyes:.

jmillsy
01-21-2005, 01:30 PM
I would love to just use PNG, but this is for a WAP site. :(

But thank you much for that, I was hoping there would be a easier way to enable it, rather than rebuild.

Thank you,
John

gbjbaanb
01-21-2005, 04:23 PM
If you have netpbm tools installed on your server (and my RH9 box came with it, so you might), you can use that instead.

you want to exec the following:

"djpeg '$src' | ppmquant 255 | ppmtogif > '$dst' ";

which converts the jpeg src to an intermediate format, converts it to 256 colours, then converts it to the gif dst.

Apparently the netpbm libs are faster and better than the GD functions, but that's only something I read on the web so I don't know if its really true.