April 2026
Intermediate
1009 pages
34h 15m
English
GD 2 by Thomas Boutell is not written exclusively for PHP, but it has reached many developers with PHP. It offers options for drawing shapes and text, but also allows existing images to be modified.
If you create a graphic with GD 2, the graphic is a PHP file. The basic structure is always the same. First, you must output the data type via the HTTP header:
header("Content-type: image/png");
Content-type is the file type of the image. You have the following options:
header("Content-type: image/gif");
for GIF or
header("Content-type: image/jpeg");
for JPEG.
GIF only supports 256 colors, all of which are collected in a color palette. Due to its area-oriented compression algorithm, GIF is ...
Read now
Unlock full access