What library does PHP offer for generating images?

PHP offers the GD library for generating images. GD is a popular image manipulation library that allows developers to create and modify images using various functions and features. By using GD library functions, developers can easily generate images dynamically based on user input or other data sources.

// Create a blank image with dimensions 200x200
$image = imagecreatetruecolor(200, 200);

// Set the background color to white
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);

// Output the image as PNG
header('Content-Type: image/png');
imagepng($image);

// Free up memory
imagedestroy($image);