How To Install ImageMagick (Image Manipulation) Tool on RHEL/CentOS and Fedora
To Install ImageMagick (Image Manipulation) Tool on RHEL/CentOS and Fedora
ImageMagick is a simple open source software suited for any image manipulation, which is used for editing, converting, creating, displaying image files. It can read and also write many image files like JPEG, GIF, PNG, TIFF and Photo CD image formats. It can be used for thumbnail and captcha creation. ImageMagick includes command line options for generating transparent and animated gif image formats and also features like sharpen, resize, rotate and adding special effects to an image. Install ImageMagick with Imagick PHP extension for PHP and ImageMagick-perl extension for Perl is explained in this article.
To Install ImageMagick
Install the required packages to compile imagick PHP extension.
[root@linuxhelp ~]# yum install php-pear php-devel gcc -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
* extras: mirror.nbrc.ac.in
* updates: mirror.nbrc.ac.in
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-4.el7 will be installed
--> Processing Dependency: libgomp = 4.8.5-4.el7 for package: gcc-4.8.5-4.el7.x86_64
.
.
.
Dependency Installed:
autoconf.noarch 0:2.69-11.el7 automake.noarch 0:1.13.4-3.el7 glibc-devel.x86_64 0:2.17-106.el7_2.6
glibc-headers.x86_64 0:2.17-106.el7_2.6 kernel-headers.x86_64 0:3.10.0-327.18.2.el7 pcre-devel.x86_64 0:8.32-15.el7_2.1
perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-Test-Harness.noarch 0:3.28-3.el7 perl-Thread-Queue.noarch 0:3.02-2.el7
php-process.x86_64 0:5.4.16-36.1.el7_2.1
Dependency Updated:
libgomp.x86_64 0:4.8.5-4.el7
Complete!
After installing php-pear ,php-devel and gcc packages, install ImageMagick software for Perl and PHP using the following command.
[root@linuxhelp ~]# yum install ImageMagick ImageMagick-devel ImageMagick-perl -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
* extras: mirror.nbrc.ac.in
* updates: mirror.nbrc.ac.in
Resolving Dependencies
--> Running transaction check
---> Package ImageMagick.x86_64 0:6.7.8.9-13.el7_2 will be installed
--> Processing Dependency: libwmflite-0.2.so.7()(64bit) for package: ImageMagick-6.7.8.9-13.el7_2.x86_64
--> Processing Dependency: libImath.so.6()(64bit) for package: ImageMagick-6.7.8.9-13.el7_2.x86_64
.
.
.
Dependency Updated:
bzip2.x86_64 0:1.0.6-13.el7 bzip2-libs.x86_64 0:1.0.6-13.el7 freetype.x86_64 0:2.4.11-11.el7
ghostscript.x86_64 0:9.07-18.el7 ghostscript-cups.x86_64 0:9.07-18.el7 jasper-libs.x86_64 0:1.900.1-29.el7
libICE.x86_64 0:1.0.9-2.el7 libSM.x86_64 0:1.2.2-2.el7 libX11.x86_64 0:1.6.3-2.el7
libX11-common.noarch 0:1.6.3-2.el7 libXext.x86_64 0:1.3.3-3.el7 libxcb.x86_64 0:1.11-4.el7
zlib.x86_64 0:1.2.7-15.el7
Complete!
Now you need to compile the imagick for PHP extension by executing the following ‘ pecl‘ command. This will install the ImageMagick and also imagick PHP extension module ‘ imagick.so‘ under /usr/lib/php/modules directory.
If you are using 64-bit system, the module directory path should be /usr/lib64/php/modules.
[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.1.tgz ...
Starting to download imagick-3.4.1.tgz (239,829 bytes)
.................................................done: 239,829 bytes
19 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] :
.
.
.
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.1
configuration option " php_ini" is not set to php.ini location
You should add " extension=imagick.so" to php.ini
It will prompt you to supply Imagemagick installation prefix and you need to press enter to auto detect.
Next, add the ‘ imagick.so‘ extension to ‘ /etc/php.ini‘ file.
[root@linuxhelp ~]# echo extension=imagick.so > > /etc/php.ini
Now restart Apache web server.
[root@linuxhelp ~]# systemctl restart httpd.service
Check imagick PHP extension by executing the following command.
[root@linuxhelp ~]# php -m | grep imagick
imagick
Alternatively, create a file known as ‘ info.php‘ under site root directory.
[root@linuxhelp ~]# vim /var/www/html/info.php
Append the following code.
< ?php
phpinfo ()
?>
Finally Open the browser and enter ‘ http://localhost/info.php‘ or ‘ http://ip-addresss/info.php‘ and check the imagick extension.
use convert --version command