You're looking at the PHP GD Library: http://php.net/manual/en/book.image.php
Using GD Library, you can use functions to work with image resources then output the final JPEG/PNG/GIF (or other image formats supported) to the browser or save it to a file.
Example from http://www.php.net/manual/en/function.imagecreate.php:
<?php
header("Content-type: image/png");
$im = @imagecreate(110, 20)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>
JPEG generation is much better than PDF since the file size is already smaller than PDF. Also, PDF requires the Adobe Acrobat Reader plugin to the browser in order for the browser to open, unlike JPEG which is already viewable by the browser.
Also, GD extension have a much more user base than other PDF extensions.