What are some common methods for generating JPG images in PHP?

One common method for generating JPG images in PHP is by using the GD library, which provides functions for creating and manipulating images. Another method is to use the Imagick extension, which offers more advanced image processing capabilities. Both libraries allow you to create JPG images by specifying the dimensions, colors, and content of the image.

// Using GD library to generate a JPG image
$width = 200;
$height = 200;
$image = imagecreate($width, $height);
$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 0, 0, 0);
imagestring($image, 5, 50, 50, 'Hello World', $text_color);
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);