There are a number of methods to manipulate an image with PHP. Internal to PHP, there is the GD library that has been the default for a number of years. Externally, ImageMagick is a popular tool. You can read about the GD library at http://www.boutell.com/gd/, and ImageMagick can be read about at http://www.imagemagick.org/.
GD is very useful for creating graphics, such as graphs, but ImageMagick is designed from the ground up to perform manipulations on the image. It's also much faster for the things we will want to do.
As a PHP developer, you must have your own test server on which you have full control. The examples in this chapter will rely on Imagick, which is a PECL extension that lets you call ImageMagick functions from within PHP. You will probably need to install it. If you prefer to use ImageMagick through a system()
call, or even prefer using GD, you should easily be able to convert the PHP code to do so.
To install Imagick in a Fedora or CentOS system, you need...