On the TutsPlus.com site they've posted a new tutorial for those needing to manipulate images in their PHP applications. In this new tutorial they walk you through the basics of using the GD image processing functionality that's included in every PHP release.
The internet would be pretty dull without images. However, maintaining and manipulating hundreds or thousands of images for your web site can be a headache. As your site design changes, you might need to modify all your images—for example, you might need to convert all your images to grayscale or resize them to 50% of their original size. You might also want to compress or crop different images. Doing this manually is time-consuming and error-prone, but with a little programming knowledge it can be automated.
In this tutorial, you will learn about the GD (Graphic Draw) library in PHP. You'll see how this library can be used to manipulate images by resizing, cropping, rotating or filtering them.
The post starts with a bit of background on GD and how to set it up on Windows versus Unix-based environments. They then get into some of the functionality that comes with GD including:
- getting data about the image
- flipping and rotating
- applying filters (ex: brightness, contrast)
The post also includes two "real world" examples of GD in use: resizing an entire directory of images and applying grayscale/contrast filters to images.