Install ImageMagick on CentOS 6


I had to install Imagick on a CentOS 6 box from source to ensure security. This meant compiling ImageMagick from source then installing the compiled binary in PHP.

# Remove all previous installations
yum remove ImageMagick
pecl uninstall ImageMagick

# Install dependencies
yum install libtool-ltdl-devel

# Create a temporary directory
mkdir tmp
cd tmp

# Fetch the latest version available, unzip it & clean, make and install
curl -OL
tar -xzf ImageMagick.tar.gz
cd ImageMagick-6.9.0-4/
./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --with-gs-font-dir=/usr/local/share/ghostscript/fonts --with-jpeg=yes --with-jp2=yes --with-png=yes --with-tiff=yes --with-bzlib=yes --with-fontconfig=yes --with-freetype=yes --with-gslib=yes --with-gvc=yes --with-png32=yes --with-png64=yes
make clean
make install

# Check convert where `convert` is installed
which convert

# Check the version (for your sanity) we are installing 6.9.0-4
# Version: ImageMagick 6.9.0-4 Q8 x86_64 2015-01-30
# Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
# Features: DPC Modules OpenMP
# Delegates (built-in): bzlib djvu fontconfig freetype gslib jng jpeg lcms ltdl openexr pangocairo png ps tiff x xml zlib
convert -version

# Update the PECL channel
pecl channel-update

# Update the PECL ImageMagick extension (select [auto detect])
sudo pecl install ImageMagick

# Add the following line to php.ini (I added it towards the bottom)
vi /etc/php.ini

# Restart apache
sudo apachectl graceful

# Go have a beer 🍻

I found ImageMagick much easier to use then GD, I prefer the OOP API provided by Imagick.