How to Add Imagemagick Support to PHP

By | February 2, 2010

In order to process images with php using image processing functions, you need to have Imagemagick support installed. Since I haven’t found any clear reference, how to do it fast, let me post my solution, it should help you to add Imagemagick support to your PHP installation.

First of all, we need to ensure we’ve got Imagemagick on our server. Please, read my previous post, where the procedure of Imagemagick setup is explained, if you don’t have it installed. You need to install Imagemagick first in order to add its functions in PHP, I hope it’s clear.

After the main library is installed, we will need another source archive, that will allow us to add Imagemagick functions to PHP. This package is called Imagick, and you’re welcome to select one package you like. I’ve taken 3.0.0b2 beta, the most recent for today.

Let’s download it to our server:

wget http://pecl.php.net/get/imagick-3.0.0b2.tgz

Extract to a folder:

tar -xzvf imagick-3.0.0b2.tgz

cd into this folder

cd imagick-3.0.0b2;

Then we need to run phpize

phpize

Then our usual list of commands:
./configure –with-imagick=/usr/local
make
make install

After you’ve built imagick, you should see something like this:

how to install imagick

Now you need to copy the created library named imagick.so to your extensions directory. However you can skip this step, if you like to deal with ling paths in your php.ini.

And the final stage is to add imagick module to php.ini. If you have copied the library to your extensions directory, you should add the following line to php.ini:

extension=imagick.so

If you have decided to keep the library at the place where it was installed, the string will look like

extension=/usr/local/lib/php/extensions/no-debug-non-zts-20060613/imagick.so

Now restart Apache and check your phpinfo(). If everything is OK, you should see:

imagick ready

You should now be able to use Imagemagick functions. Feel free to ask me any questions you have.