GD Graphics Library


The GD Graphics Library is a graphics software library by Thomas Boutell and others for dynamically manipulating images. Its native programming language is ANSI C, but it has interfaces for many other programming languages. It can create GIFs, JPEGs, PNGs, and WBMPs. Support for drawing GIFs was dropped in 1999 when Unisys revoked the royalty-free license granted to non-commercial software projects for the LZW compression method used by GIFs. When the Unisys patent expired worldwide on July 7, 2004, GIF support was subsequently re-enabled.
GD originally stood for "GIF Draw". However, since the revoking of the Unisys license, it has informally stood for "Graphics Draw".
GD can create images composed of lines, arcs, text, other images, and multiple colors. Version 2.0 adds support for truecolor images, alpha channels, resampling, and many other features.
GD supports numerous programming languages including C, PHP, Perl, Python, OCaml, Tcl, Lua, Pascal, GNU Octave, REXX, Ruby and Go. In addition, the "Fly" command line interpreter allows for image creation using GD. GD scripts can thus be written in potentially any language and run using this tool.
GD is extensively used with PHP, where a modified version supporting additional features is included by default as of PHP 4.3 and was an option before that. As of PHP 5.3, a system version of GD may be used as well, to get the additional features that were previously available only to the bundled version of GD.

Example

The following is an example which outputs a 3D looking pie chart.

// Create an image
$image = imagecreatetruecolor;
// Allocate some colors
$white = imagecolorallocate;
$gray = imagecolorallocate;
$darkgray = imagecolorallocate;
$navy = imagecolorallocate;
$darknavy = imagecolorallocate;
$red = imagecolorallocate;
$darkred = imagecolorallocate;
// Make the 3D effect
for
imagefilledarc;
imagefilledarc;
imagefilledarc;
// Flush the image
header;
imagepng;
imagedestroy;
?>