GD Functions


The GD graphics library is available from www.boutell.com/gd/. Depending on your UNIX distribution, any upgrades you may have installed, and the current version, various functions may be available and others unavailable. For example, versions prior to 1.3 containing GIF support may either have proprietary LZW-based GIF compression or PNG-only support due to licensing issues. Versions 1.3 and above contain non-LZW-based GIF compression code, which creates slightly larger files, as well as PNG support. Further up the version chain, version 1.5 contains a GD2 format using zlib, while GIF support was removed again in version 1.6. JPEG support was added with version 1.8. Fortunately, the phpinfo() function includes the version of GD that PHP was linked against, so you can deduce which functions are available. You'll also need to install libpng, libjpg, and the Freetype library to make non-GIF functions available. Remember that if you send the image to the browser, you must also send a Content-type HTTP header. For example, to send a header for a GIF file, the correct function call would be header("Content-type: image/gif")() . Please note that the origin of pixel coordinates is the upper-left corner of the image.