Chapter 4. Manipulating Images with the GD Extension

In This Chapter

  • Configuring GD

  • Manipulating the size and coloring of images with GD

  • Adding text to images with GD

Image manipulation is one of those things that either makes you cringe or gives you a rush of creative energy. Regardless of which type of programmer you are, creating dozens of versions of the same image is probably not one of the top items on your priority list. Let's face it, the task is boring, repetitive, and time consuming.

Hey, wait! Isn't that why we invented computers in the first place — to take on tasks that are boring, repetitive, and time consuming? Absolutely. And image manipulations are a perfect candidate for delegation to the computer. With the GD extension, telling the computer to "make a copy of this image in each of the following colors, but only change the background color" is relatively easy.

What is GD, anyway? Technically, the acronym stands for Graphics Draw, but you'll be hard pressed to find someone who uses that term. Tell a PHP developer you're using GD to manipulate images and odds are she'll know what you're talking about.

NOTE

The GD extension allows you very fine control over your images, so there's really no limit to what you can generate on the fly. The best way to get comfortable using GD is to hop right in and experiment.

Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® 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.