Graphic Draw (GD)
GD is the name of a PHP extension that can manipulate several image formats, such as GIF, PNG, JPEG, WBMP, and XPM, and draw graphics.
The GD extension is a binding to the libgd graphics library. It provides functions to create images from scratch, or to load them from an existing file or a binary string, then draw shapes, lines, text, and apply filters, before outputting the result directly to the browser or saving it to disk. Typical uses include generating thumbnails, watermarking uploaded pictures, building CAPTCHAs, drawing charts, or producing dynamically generated images such as Open Graph previews.
GD ships as a bundled extension with PHP, but it must still be enabled, either at compile time with --with-gd, or by loading the gd.so / php_gd.dll shared extension in php.ini. Depending on how the underlying libgd was built, support for specific formats such as JPEG, WebP, or FreeType-based text rendering may or may not be available, which can be checked with gd_info().
GD is not the only image library available for PHP: the Imagick extension, a binding to ImageMagick, offers a richer feature set and support for more formats, at the cost of a heavier dependency. Because GD functions accept resource-like GdImage objects and can decode attacker-supplied files, careless use, for instance passing unchecked, remotely-provided data to imagecreatefromstring(), has historically been a source of security vulnerabilities.
<?php
// Creating a PNG image with PHP
// Extract from the PHP documentation
header("Content-type: image/png");
$string = $_GET['text'];
$im = imagecreatefrompng(images/button1.png);
$orange = imagecolorallocate($im, 220, 210, 60);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagepng($im);
?>