16.2. Creating Images

All the functions in this section require the GD library. If you haven't compiled it as part of your PHP module, either load it automatically by editing php3.ini or use the dl function. Some of these functions also require other libraries, which allow you to use font files.

To get started, you can use either imagecreate to start with a blank graphic or a function such as imagecreatefrompng to load a PNG from a file. Coordinates in these functions treat (0, 0) as the top left corner and refer to pixels. Likewise, any size arguments refer to pixels.

When creating images with these functions, you can't simply decide to output an image in the middle of a script that outputs HTML. You must create a separate script that sends ...

Get Core PHP Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.