Install ImageMagick on CentOS 6

  • Last Created On Dec 10, 2024
  • 8
0 0

ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PNG, Postscript, SVG, and TIFF. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

ImageMagick can be installed by either using the remi repository, or by compiling the source code from the latest stable release. Following the installation guide is another guide on how to install the ImageMagick PHP extension (imagick).

Simple install from remi repository

If you have not installed the epel repository, install it now.

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6*.rpm

Next, install the remi repository:

wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm

An additional step is required to enable the remi repository:

Use your favorite text editor to open /etc/yum.repos.d/remi.repo. Look for the remi section and find enabled=0 and change it to enabled=1.

Make sure that the required dependencies are installed:

yum install -y gcc php-devel php-pear

Then install ImageMagick:

yum install -y ImageMagick ImageMagick-devel

Extra: If you plan on using ImageMagick in perl scripts:

yum install ImageMagick-perl

The installation is now complete.

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

Now, fetch the source code:

wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar xvzf ImageMagick.tar.gz
cd ImageMagick*

Configure and compile the source code. Depending on your server specs, this may take some time to complete.

./configure
make
make install

Verify that the compile and install were successful:

convert --version 

Install PHP extension

Install the imagick PHP extension module imagick.so:

pecl install imagick

You will be asked to provide the ImageMagick installation prefix. Press [ENTER] to auto detect. You may get this error following 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 due to a secured and mounted /tmp directory. You may have setup your /tmp folder in this way as part of your server security lock-down. To resolve this error temporarily, remove the /tmp line in /etc/fstab and reboot. Run the pecl command again. When installation completes, you can add the /tmp line back to /etc/fstab and reboot. Using the umount command will not work if /tmp has the nosuid,noexec,nodev options.

Next, add the imagick.so extension to the php.ini file. Start by locating your php.ini file. It is usually found in /etc.

php -i | grep "Loaded Configuration File"

Use a text editor to open php.ini and look for the dynamic extension section. Add extension=imagick.so, then save.

Check the php extension list to verify that imagick has installed correctly:

php -m | grep imagick

If you are running a webserver, such as Apache, remember to restart it:

service httpd restart

References

  1. The official ImageMagick website.
Views: 8

Recent Articles

  • How to Install JAX with ROCm Acceleratio...
    96
  • Deploy a PyTorch Workspace on a Vultr Cl...
    71
  • Managing Backup Storage
    83
  • Automating FTP Backups in Windows Server
    71
  • Automating FTP Backups in Linux
    75

Popular Articles

  • Our General Terms & Conditions
    2632
  • Our Privacy Policy
    2478
  • Our Cookies Policy
    275
  • Our Terms of Use
    153
  • How to Install JAX with ROCm Acceleratio...
    96