GD Graphics Library
Developer(s)Thomas Boutell
Initial release1994 (1994)
Stable release
2.3.3 Edit this on Wikidata / 12 September 2021 (12 September 2021)[1]
Repositoryhttps://github.com/libgd/libgd
Written inC
Operating systemCross-platform
TypeGraphics library
LicenseBSD-like license
Websitelibgd.github.io

The GD Graphics Library is a graphics software library for dynamically manipulating images. It can create GIFs, JPEGs, PNGs, and WBMPs. The images can be composed of lines, arcs, text (using program-selected fonts), other images, and multiple colors, supporting truecolor images, alpha channels, resampling, and many other features.

Its native programming language is ANSI C, but it has interfaces for many other programming languages. 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 ("on the fly") using GD. GD scripts can thus be written in potentially any language and run using this tool.[2]

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.

History

The software was developed in 1994 by Thomas Boutell and others.

GD originally stood for "GIF Draw". However, since the revoking of the Unisys license, it has informally stood for "Graphics Draw".

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.

Version 2.0 added support for truecolor images, alpha channels, resampling (for smooth resizing of truecolor images), and many other features.


Example

The following is an example which outputs a 3D looking pie chart (from the PHP GD documentation on the imagefilledarc() function).

<?php
    // Create an image
    $image = imagecreatetruecolor(100, 100);

    // Allocate some colors
    $white    = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
    $gray     = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
    $darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90);
    $navy     = imagecolorallocate($image, 0x00, 0x00, 0x80);
    $darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50);
    $red      = imagecolorallocate($image, 0xFF, 0x00, 0x00);
    $darkred  = imagecolorallocate($image, 0x90, 0x00, 0x00);

    // Make the 3D effect
    for ($i = 60; $i > 50; $i--) {
        imagefilledarc($image, 50, $i, 100, 50, 0,   45, $darknavy, IMG_ARC_PIE);
        imagefilledarc($image, 50, $i, 100, 50, 45,  75, $darkgray, IMG_ARC_PIE);
        imagefilledarc($image, 50, $i, 100, 50, 75, 360, $darkred,  IMG_ARC_PIE);
    }

    imagefilledarc($image, 50, 50, 100, 50,  0,  45, $navy, IMG_ARC_PIE);
    imagefilledarc($image, 50, 50, 100, 50, 45,  75, $gray, IMG_ARC_PIE);
    imagefilledarc($image, 50, 50, 100, 50, 75, 360, $red,  IMG_ARC_PIE);

    // Flush the image
    header('Content-type: image/png');
    imagepng($image);
    imagedestroy($image);
?>

See also

References

  1. "LibGD releases". GitHub.
  2. Gleeson, Martin (1999-01-15). "fly: create images on the fly". Archived from the original on 2000-09-03.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.