Starting from PHP version 4.3, its own bundled GD2 library was included, and users can download and configure it themselves. If you want to check whether your PHP version supports the GD module (supports JPEG, PNG, WBMP but no longer supports GIF), the following method is one way:
```php
if (!function_exists('imagecreate')) {
die('The server does not support the GD module.');
}
```
If it is not supported, how do you configure it? Download the DLL file for the GD module, modify the `php.ini` file, and restart the server.
Hereafter, we will refer to PHP image creation as PS.
When you plan to use PS, you should follow these steps, which are mandatory:
1. Create a basic PS object (let's assume `$image`), fill in the background (default black). All subsequent PS operations will be based on this background image.
2. Draw on `$image`.
3. Output the image.
4. Destroy the object and clear the used memory.
First, let’s get familiar with a few commonly used functions. These functions are described in detail in the PHP manual, and I'll briefly summarize them here.
```php
resource imagecreate ( int $x_size, int $y_size )
```
`imagecreate()` returns an image identifier representing a blank image of size `$x_size` by `$y_size`.
This function is similar to `imagetruecolor($width, $height)`.
```php
int imagecolorallocate ( resource $image, int $red, int $green, int $blue )
```
`imagecolorallocate()` returns a color identifier consisting of the specified RGB components. The `$image` parameter is the return value of the `imagecreatetruecolor()` function. `$red`, `$green`, and `$blue` represent the red, green, and blue components of the desired color. These parameters are integers ranging from 0 to 255 or hexadecimal values from `0x00` to `0xFF`. You must call `imagecolorallocate()` to create each color used in the image represented by `$image`.
```php
bool imagefill ( resource $image, int $x, int $y, int $color )
```
`imagefill()` performs a flood fill on the image `$image` at coordinates `$x`, `$y` (the top-left corner of the image is 0, 0) using the color `$color`. This fills all adjacent points that have the same color as the point at (`$x`, `$y`).