AMP AMP

How to Install ImageMagick on CentOS 7.6

Installation of ImageMagick on CentOS 7.6

ImageMagick is a free and open-source software suite used for creating, editing, composing, or converting bitmap images. With ImageMagick, you can it is easy for you to read and write images in a variety of formats like GIF, JPEG, PNG, Postscript, and TIFF. You can also use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images and much more. This tutorial covers the installation of ImageMagick on CentOS 7.6.

Requirements for ImageMagick

Deveploment tools PHP and its modules

Check the CentOS version by using the following command.

[root@linuxhelp ~]# rpm -q centos-release
centos-release-7-6.1810.2.el7.centos.x86_64

The installation of ImageMagick requires certain development tools, and to add them to your system, you need to run the following command

 [root@linuxhelp ~]# yum groupinstall "Development Tools" -y
Loaded plugins: fastestmirror, langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                   | 6.7 kB  00:00:00     
 * base: centos.myfahim.com
 * epel: mirror1.ku.ac.th
 * extras: centos.myfahim.com
 * remi-php56: mirror.neolabs.kz
.
.
  perl-Test-Harness.noarch 0:3.28-3.el7                   perl-Thread-Queue.noarch 0:3.02-2.el7              
  perl-XML-Parser.x86_64 0:2.41-10.el7                    perl-srpm-macros.noarch 0:1-8.el7                  
  subversion-libs.x86_64 0:1.7.14-14.el7                  systemtap-client.x86_64 0:3.3-3.el7                
  systemtap-devel.x86_64 0:3.3-3.el7                     

Dependency Updated:
  glibc.x86_64 0:2.17-260.el7_6.5    glibc-common.x86_64 0:2.17-260.el7_6.5  libgcc.x86_64 0:4.8.5-36.el7_6.2 
  libgomp.x86_64 0:4.8.5-36.el7_6.2  libstdc++.x86_64 0:4.8.5-36.el7_6.2    
Complete!

Once the development tools are installed, you can can start the installation of ImageMagick by running the following command.

[root@linuxhelp ~]# yum install ImageMagick ImageMagick-devel -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.myfahim.com
* epel: repos.del.extreme-ix.org
* extras: centos.myfahim.com
* remi-php56: mirror.veriteknik.net.tr
* remi-safe: mirror.veriteknik.net.tr
.
.
.
Dependency Installed:
 OpenEXR-libs.x86_64 0:1.7.1-7.el7                    bzip2-devel.x86_64 0:1.0.6-13.el7                     
 freetype-devel.x86_64 0:2.8-12.el7_6.1               ghostscript-devel.x86_64 0:9.07-31.el7_6.11           
 ilmbase.x86_64 0:1.0.3-7.el7                         jasper-devel.x86_64 0:1.900.1-33.el7                  
 libICE-devel.x86_64 0:1.0.9-9.el7                    libSM-devel.x86_64 0:1.2.2-2.el7                      
 libXext-devel.x86_64 0:1.3.3-3.el7                   libXt-devel.x86_64 0:1.1.5-3.el7                      
 libjpeg-turbo-devel.x86_64 0:1.2.90-6.el7            libpng-devel.x86_64 2:1.5.13-7.el7_2                  
 libtiff-devel.x86_64 0:4.0.3-27.el7_3                libwmf-lite.x86_64 0:0.2.8.4-41.el7_1                 
 zlib-devel.x86_64 0:1.2.7-18.el7                    

Dependency Updated:
 freetype.x86_64 0:2.8-12.el7_6.1                         ghostscript.x86_64 0:9.07-31.el7_6.11              
 ghostscript-cups.x86_64 0:9.07-31.el7_6.11              

Complete!

Install the php pear extension by using the following command.

[root@linuxhelp ~]# yum install php-pear
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.myfahim.com
* epel: mirror1.ku.ac.th
* extras: centos.myfahim.com
* remi-php56: mirror.uta.edu.ec
* remi-safe: mirror.uta.edu.ec
* updates: centos.myfahim.com
Resolving Dependencies
--> Running transaction check
.
.
.
 Installing : php-fedora-autoloader-1.0.0-1.el7.noarch                                                   1/3 
 Installing : php-process-5.6.40-8.el7.remi.x86_64                                                       2/3 
 Installing : 1:php-pear-1.10.9-2.el7.remi.noarch                                                        3/3 
 Verifying  : php-process-5.6.40-8.el7.remi.x86_64                                                       1/3 
 Verifying  : php-fedora-autoloader-1.0.0-1.el7.noarch                                                   2/3 
 Verifying  : 1:php-pear-1.10.9-2.el7.remi.noarch                                                        3/3 

Installed:
 php-pear.noarch 1:1.10.9-2.el7.remi                                                                         

Dependency Installed:
 php-fedora-autoloader.noarch 0:1.0.0-1.el7              php-process.x86_64 0:5.6.40-8.el7.remi             

Complete!

You should also install the php-devel extension, which can be done with the help of the following command.

[root@linuxhelp ~]# yum install php-devel -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.myfahim.com
* epel: ftp.jaist.ac.jp
* extras: centos.myfahim.com
* remi-php56: mirror.neolabs.kz
* remi-safe: mirror.neolabs.kz
* updates: centos.myfahim.com
Resolving Dependencies
--> Running transaction check
.
.
.
Dependency Installed:
 keyutils-libs-devel.x86_64 0:1.5.8-3.el7           krb5-devel.x86_64 0:1.15.1-37.el7_6                      
 libcom_err-devel.x86_64 0:1.42.9-13.el7            libedit-devel.x86_64 0:3.0-12.20121213cvs.el7            
 libselinux-devel.x86_64 0:2.5-14.1.el7             libsepol-devel.x86_64 0:2.5-10.el7                       
 libverto-devel.x86_64 0:0.2.5-4.el7                libxml2-devel.x86_64 0:2.9.1-6.el7_2.3                   
 ncurses-devel.x86_64 0:5.9-14.20130511.el7_4       openssl-devel.x86_64 1:1.0.2k-16.el7_6.1                 
 pcre-devel.x86_64 0:8.32-17.el7                    php-pecl-jsonc-devel.x86_64 0:1.3.10-2.el7.remi.5.6      
 xz-devel.x86_64 0:5.2.2-1.el7                     

Dependency Updated:
 krb5-libs.x86_64 0:1.15.1-37.el7_6                   krb5-workstation.x86_64 0:1.15.1-37.el7_6             
 libkadm5.x86_64 0:1.15.1-37.el7_6                    openssl.x86_64 1:1.0.2k-16.el7_6.1                    
 openssl-libs.x86_64 1:1.0.2k-16.el7_6.1             

Complete!

Now you should install ImageMagick using pecl command.

 [root@linuxhelp ~]# pecl install Imagick
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading imagick-3.4.4.tgz ...
Starting to download imagick-3.4.4.tgz (253,434 bytes)
.....................................................done: 253,434 bytes
19 source files, building
running: phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
Please provide the prefix of ImageMagick installation [autodetect] : 
building in /var/tmp/pear-build-rootDpnijK/imagick-3.4.4
.
.
Build process completed successfully
Installing '/usr/lib64/php/modules/imagick.so'
Installing '/usr/include/php/ext/imagick/php_imagick_shared.h'
install ok: channel://pecl.php.net/imagick-3.4.4
configuration option "php_ini" is not set to php.ini location
You should add "extension=imagick.so" to php.ini


Add extension=imagick.so in vim /etc/php.ini
 [root@linuxhelp ~]# vim /etc/php.ini

Check the ImageMagick you've installed by using the following command

[root@linuxhelp ~]# php -i | grep Imagick
PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
Imagick compiled with ImageMagick version => ImageMagick 6.7.8-9 2019-02-01 Q16 http://www.imagemagick.org
Imagick using ImageMagick library version => ImageMagick 6.7.8-9 2019-02-01 Q16 http://www.imagemagick.org

Enter into the downloads directory.

[root@linuxhelp ~]# cd /root/

List out the contents with the following command.

root@linuxhelp ~]# ls
anaconda-ks.cfg  Documents  initial-setup-ks.cfg  Pictures  remi-release-7.rpm  Videos
Desktop          Downloads  Music                 Public    Templates
[root@linuxhelp ~]# cd Downloads
ImageMagick has been installed. Now you can check the functioning of the newly installed ImageMagik. Display the image you want to convert
[root@linuxhelp Downloads]# display

List out the details

[root@linuxhelp Downloads]# ll
total 36
-rw-r--r-- 1 root root 35961 May 18 12:36 image.jpg

Display the image that needs to be displayed in the picture

[root@linuxhelp Downloads]# display image.jpg

With this, this tutorial on ImageMagik installation comes to an end.

FAQ
Q
What are other php accelerators available in Linux for ImageMagick?
A
You can refer the following list



eAccelerator

ionCube PHP Accelerator

Turck MMCache

Xcache
Q
Name some alternatives same as PHPlist newsletter for ImageMagick?
A
Use the following list for alternatives.



Sympa



Mailtrain



Maily Herald



OpenEMM
Q
What java version is preferable for php storm in ImageMagick?
A
Java 8 is advisable for php storm
Q
What are all the PHP version supported for this application for Imagemagick?
A
As of now owing to the current update, the php version from 5.3/5.4/5.5/5.6/7.0. can be supported.
Q
How to compile ImageMagick from source code?
A
You shall refer the following tutorial https://www.linuxhelp.com/how-to-install-imagemagick-from-source-on-centos-7/