Technology Blog

How to install ImageMagick + PHP Imagick on CentOS

0

ImageMagick is an image development suite that allows you to create, manipulate or convert bitmap images. It supports many common image format such as: GIF, JPEG, JPEG-2000, PDF, PNG, SVG, TIFF, DPX, EXR, among many others. ImageMagick is very used to rotate, mirror, resize, draw, apply many more special effects to your images.

ImageMagick

You can use ImageMagick from the command line, but it also supports integration with many popular languages such as PHP, Perl or C++. Today we will take a look about how to install ImageMagick and Imagick PHP library on CentOS Linux.

Tutorial Requirements

Ensure you have php-pear installed, which will be used later to install Imagick PHP module.
If you don’t have pear, you can install using Yum:

yum install php-pear

Install ImageMagick

yum install ImageMagick*

Install Imagick, the ImageMagick PHP library

pecl install Imagick

The output shoudl look like this:

[[email protected]:~]pecl install Imagick downloading imagick-3.1.2.tgz ... Starting to download imagick-3.1.2.tgz (94,657 bytes) .....................done: 94,657 bytes 15 source files, building running: phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525 Please provide the prefix of Imagemagick installation [autodetect] : building in /root/tmp/pear/pear-build-rootJJlLyo/imagick-3.1.2 running: /root/tmp/pear/imagick/configure --with-imagick

Check if Imagick was installed ok:

php -i | grep Imagick

You should see this output while running:

 [[email protected]:~]php -i | grep Imagick -i imagick imagick module => enabled imagick module version => 3.1.2 imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator imagick.locale_fix => 0 => 0 imagick.progress_monitor => 0 => 0