ImageMagick is a software package that is used to edit, create, or transform bitmap images. It can read and write images in various formats including DPX, EXR-2000, PDF, PNG, Postscript, SVG and TIFF. ImageMagick can be installed either through the remi repository or by compiling the source from the latest stable release. The installation guide is followed by another installation guide for the ImageMagick PHP extension (imagick).
Next Step installation from Remi Repository
You can install this repository using the following command:
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6*.rpm
Next, you need to install the remi repository:
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm
An additional following step is required to enable the remi repository:
- Use your favorite text editor to open /etc/yum.repos.d/remi.repo. You need to find the remi section and enabled=0 change it to enabled=1.
- Make sure the required dependencies are installed:
yum install -y gcc php-devel php-pear
- Then install ImageMagick:
yum install -y ImageMagick ImageMagick-devel
Optional!
if you plan on using ImageMagick in perl scripts:
yum install ImageMagick-perl
On this steps, the installation’ll be done.
Install from source code
First install dependencies:
yum -y groupinstall 'Development Tools'
yum -y install bzip2-devel freetype-devel libjpeg-devel libpng-devel libtiff-devel giflib-devel zlib-devel ghostscript-devel djvulibre-devel libwmf-devel jasper-devel libtool-ltdl-devel libX11-devel libXext-devel libXt-devel lcms-devel libxml2-devel librsvg2-devel OpenEXR-devel php-devel
Upon successful installation, you will be provided with the dedicated source code:
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar xvzf ImageMagick.tar.gz
cd ImageMagick*
Next, you need to compile the source code by following command
./configure
make
make instal
You can check the successful compilation using the following command:
convert --version
Install PHP extension
Install the imagick php imagick.so extension module:
pecl install imagick
You will be prompted for the ImageMagick installation prefix. Press ENTER to auto detect. You can get this error after the pecl command:
"Error shtool at '/var/tmp/imagick/build/shtool' does not exist or is not executable. Make sure that the file exists and is executable and then rerun this script"
This is related to the protected and mounted /tmp directory. You may have configured your /tmp folder this way as part of protecting your server. To temporarily fix this error, remove the /tmp/etc/fstab line and reboot. Run the pecl command again. When the installation is complete, you can add /etc/fstab to /tmp and reboot. Using the umount command will not work if /tmp has the nosuid, noexec, nodev options. Then add the imagick.so extension to your php.ini file. Start by looking for your php.ini file. Usually found in /etc files.
php -i | grep "Loaded Configuration File"
Use a text editor to open php.ini and find the dynamic extension section. Add extension = imagick.so then save. Check the php extension list to make sure imagick is installed correctly:
php -m | grep imagick
If you’re using a web server like Apache, remember to restart it:
service httpd restart
Done!