Installing and using PHP ImageMagick (Imagick) Module

June 9th, 2009

Warning: This post is 14 years old. Some of this information may be out of date.


On an Ubuntu System:

sudo apt-get install imagemagick libmagick9-dev php5-imagick php5-dev
tar xvfz imagick-3.0.0b1.tgz
cd imagick-3.0.0b1
phpize && ./configure
sudo make
sudo make install
sudo apache2ctl graceful

Example Usage:

//Create two Imagick objects
$first = new Imagick('tshirt.png');
$second = new Imagick('photo.jpg');
$first->compositeImage($second, Imagick::COMPOSITE_MULTIPLY, 220, 141);
//new image is saved as final.jpg
header('content-type: image/jpeg');
echo $first->getImage();