How to install PHP ImageMagick on CentOS 7
To install PHP ImageMagick on CentOS 7
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. It is really very easy to install ImageMagic and in this tutorial, you will learn about the method to install it on CentOS 7.
Installing ImageMagick
The installation of ImageMagick requires certain development tools, and to add them to your system, you need to run the following command, which installs them all together.
[root@linuxhelp ~]# yum groupinstall " Development Tools" -y
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/4): base/7/x86_64/group_gz | 156 kB 00:01
(2/4): extras/7/x86_64/primary_db | 129 kB 00:01
(3/4): base/7/x86_64/primary_db | 5.7 MB 00:23
(4/4): updates/7/x86_64/primary_db | 3.6 MB 00:29
Loading mirror speeds from cached hostfile
* base: centos.myfahim.com
* extras: mirrors.viethosting.com
* updates: mirrors.vonline.vn
.
.
.
Dependency Updated:
boost-system.x86_64 0:1.53.0-27.el7 dyninst.x86_64 0:9.3.1-1.el7
gettext.x86_64 0:0.19.8.1-2.el7 gettext-libs.x86_64 0:0.19.8.1-2.el7
glibc.x86_64 0:2.17-196.el7 glibc-common.x86_64 0:2.17-196.el7
libgcc.x86_64 0:4.8.5-16.el7 libgomp.x86_64 0:4.8.5-16.el7
libstdc++.x86_64 0:4.8.5-16.el7 rpm.x86_64 0:4.11.3-25.el7
rpm-build-libs.x86_64 0:4.11.3-25.el7 rpm-libs.x86_64 0:4.11.3-25.el7
rpm-python.x86_64 0:4.11.3-25.el7 systemtap-runtime.x86_64 0:3.1-3.el7
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
* extras: mirrors.viethosting.com
* updates: mirrors.vonline.vn
Resolving Dependencies
--> Running transaction check
---> Package ImageMagick.x86_64 0:6.7.8.9-15.el7_2 will be installed
--> Processing Dependency: libwmflite-0.2.so.7()(64bit) for package: ImageMagick-6.7.8.9-15.el7_2.x86_64
--> Processing Dependency: libImath.so.6()(64bit) for package: ImageMagick-6.7.8.9-15.el7_2.x86_64
.
.
.
.
libX11.x86_64 0:1.6.5-1.el7
libX11-common.noarch 0:1.6.5-1.el7
libXext.x86_64 0:1.3.3-3.el7
libXt.x86_64 0:1.1.5-3.el7
libtiff.x86_64 0:4.0.3-27.el7_3
libxcb.x86_64 0:1.12-1.el7
zlib.x86_64 0:1.2.7-17.el7
Complete!
Also, it is required for you to install the php pear extension, so run the following command.
[root@linuxhelp ~]# yum install php-pear
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.nhanhoa.com
* extras: mirrors.nhanhoa.com
* updates: centos-hn.viettelidc.com.vn
Resolving Dependencies
--> Running transaction check
---> Package php-pear.noarch 1:1.9.4-21.el7 will be installed
--> Processing Dependency: php-zlib for package: 1:php-pear-1.9.4-21.el7.noarch
--> Processing Dependency: php-xml for package: 1:php-pear-1.9.4-21.el7.noarch
--> Processing Dependency: php-tokenizer for package: 1:php-pear-1.9.4-21.el7.noarch
--> Processing Dependency: php-posix for package: 1:php-pear-1.9.4-21.el7.noarch
--> Processing Dependency: php-pcre for package: 1:php-pear-1.9.4-21.el7.noarch
--> Processing Dependency: php-ftp for package: 1:php-pear-1.9.4-21.el7.noarch
--> Processing Dependency: php-cli for package: 1:php-pear-1.9.4-21.el7.noarch
--> Processing Dependency: php-bz2 for package: 1:php-pear-1.9.4-21.el7.noarch
.
.
.
.
.
Installing : php-process-5.4.16-42.el7.x86_64 5/6
Installing : 1:php-pear-1.9.4-21.el7.noarch 6/6
Verifying : php-cli-5.4.16-42.el7.x86_64 1/6
Verifying : php-xml-5.4.16-42.el7.x86_64 2/6
Verifying : libzip-0.10.1-8.el7.x86_64 3/6
Verifying : php-process-5.4.16-42.el7.x86_64 4/6
Verifying : php-common-5.4.16-42.el7.x86_64 5/6
Verifying : 1:php-pear-1.9.4-21.el7.noarch 6/6
Installed:
php-pear.noarch 1:1.9.4-21.el7
Dependency Installed:
libzip.x86_64 0:0.10.1-8.el7 php-cli.x86_64 0:5.4.16-42.el7
php-common.x86_64 0:5.4.16-42.el7 php-process.x86_64 0:5.4.16-42.el7
php-xml.x86_64 0:5.4.16-42.el7
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
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.nhanhoa.com
* extras: mirrors.nhanhoa.com
* updates: mirror.vbctv.in
Resolving Dependencies
--> Running transaction check
---> Package php-devel.x86_64 0:5.4.16-42.el7 will be installed
--> Processing Dependency: pcre-devel(x86-64) for package: php-devel-5.4.16-42.el7.x86_64
--> Running transaction check
---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed
--> Processing Dependency: pcre(x86-64) = 8.32-17.el7 for package: pcre-devel-8.32-17.el7.x86_64
--> Running transaction check
.
.
.
.
Verifying : pcre-devel-8.32-17.el7.x86_64 3/4
Verifying : pcre-8.32-12.el7.x86_64 4/4
Installed:
php-devel.x86_64 0:5.4.16-42.el7
Dependency Installed:
pcre-devel.x86_64 0:8.32-17.el7
Dependency Updated:
pcre.x86_64 0:8.32-17.el7
Complete!
Now you should install ImageMagick using pecl command.
[root@linuxhelp ~]# pecl install Imagick
downloading imagick-3.4.3.tgz ...
Starting to download imagick-3.4.3.tgz (245,410 bytes)
...................................................done: 245,410 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] :
building in /var/tmp/pear-build-rootwYkDqq/imagick-3.4.3
running: /var/tmp/imagick/configure --with-imagick
.
.
.
.
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.3
configuration option " php_ini" is not set to php.ini location
You should add " /" to php.ini
It doesn' t get over with this, you should also add extension=imagick.so in vim /etc/php.ini, that can be done with the help of the following command.
[root@linuxhelp ~]# vim /etc/php.ini extension=imagick.so [root@linuxhelp ~]# php -i | grep Imagick imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator Imagick compiled with ImageMagick version => ImageMagick 6.7.8-9 2016-06-16 Q16 http://www.imagemagick.org Imagick using ImageMagick library version => ImageMagick 6.7.8-9 2016-06-16 Q16 http://www.imagemagick.org
ImageMagick has been installed. Now you can check the functioning of the newly installed ImageMagik. Dispay the image you want to convert.
[root@linuxhelp Downloads]#display
The image of ImageMagick gets displayed on your screen.
Now, get into the folder and start the conversion with the help of the commands highlighted below.
[root@linuxhelp ~]# cd /root/Downloads/ [root@linuxhelp Downloads]# ll total 20 -rw-r--r-- 1 root root 16473 Nov 2 11:26 relax.jpg [root@linuxhelp Downloads]# display relax.jpg
The image that is to be converted gets displayed on your screen.
You can now convert the format of the image.
[root@linuxhelp Downloads]# convert relax.jpg relax.png
Once the conversion is done, you can check if the conversion took place.
[root@linuxhelp Downloads]# ll
total 340
-rw-r--r-- 1 root root 16473 Nov 2 11:26 relax.jpg
-rw-r--r-- 1 root root 326026 Nov 2 11:41 relax.png
Also, you can check the image information for further clarification.
[root@linuxhelp Downloads]# display relax.png
Thus concludes the installation process of ImageMagik, and the method to covert an image from one format to the other.
Comments ( 3 )