Image Magick HOWTO

Install Image Magick itself:

aptitude install imagemagick

There are several modules for PHP which act as wrappers to Image Magick:

IMagick

MagickWand for PHP

This HOWTO uses IMagick because MagickWand does not appear to be in Debian.

There is a Debian package for the IMagick PHP5 module named php5-imagick, but it's version 0.9 in Etch which is too old to work with most code.

Instead we install and compile the IMagick PHP module through the PECL, which is a part of the PEAR libraries. Install these as follows:

aptitude install php-pear

The following Debian packages will be needed by PECL when it compiles the module for us:

aptitude install php5-dev libmagick9-dev build-essential

Now install and compile the PHP module itself:

pecl install imagick

When prompted, allow it to auto-detect the Image Magick base path.

Finally, load the IMagick PHP module in your server (or your site's) php.ini:

extension=imagick.so

You should now be able to call Image Magic with code such as the following example:

$myimage = new Imagick('example.jpg');
$myimage->thumbnailImage($new_width,$new_height,true); // Resize image - 'true' ensures aspect ratio is kept

Discussion

Enter your comment:

Subscribe to the RSS feed for Andy's Debian HOWTOs

Article from Andy's Debian HOWTOs (http://www.besy.co.uk/debian/debian)

 
debian/how_to_setup_and_use_imagemagick_with_php.txt · Last modified: 2008/08/01 22:56 (external edit) · [Old revisions]
Recent changes RSS feed Powered by Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki