Willing to install ImageMagick on CentOS? We can help you in installing it.
ImageMagick is a tool used for displaying, converting, and editing images.
At Bobcares, we often receive requests to enable ImageMagick and fix its errors as a part of our Server Management Services.
Today, let’s see how our Support Engineers install ImageMagick and fix its error.
How we install ImageMagick on CentOS?
Now, let’s take a look at how our Support Engineers install ImageMagick.
1. Install required packages
First, our Support Engineers install required packages. They include PHP-pear, PHP-devel, and GCC packages to compile the Imagick PHP extension.
We install the PHP pear extension using the below command.
yum install php-pearThen, we install the PHP-devel extension using the command.
yum install php-develFinally, we install the GCC extension by running the below command.
yum install gcc2. Install ImageMagick
After installing ImageMagick packages we then install ImageMagick. For that, we use the below command.
yum install ImageMagick yum install ImageMagick-devel3. Install ImageMagick PHP Extension
Once, the installation of ImageMagick is completed, we can further install PHP extension. So that we can use it through PHP code. We use the below command for the installation.
pecl install imagick echo "extension=imagick.so" > /etc/php.d/imagick.ini4. Restart Apache and check the installation
After completing the above steps, we finally restart the Apache. We do this using the command.
service httpd restartCommon errors relating to ImageMagick on CentOS
It is natural to come across an error during the installation process or after the installation completes. Similarly, the ImageMagick can also run into errors anytime.
Let’s see how our Support Engineers fix it.
1. Error during installation
Recently, one of our customers experienced an error during the installation process. And he received the below error message:
From the above error, we can see that the customer is using the Remi repository. So our Support Engineers suggested running the below command to fix this error.
yum install php-pecl-imagick2. Permissions error
There was another error reported by one of our customers. Here is the error message:
"ImageMagick reported an error: convert: unable to open image `files/images/image.jpg': Permission denied.Our Support Engineers started troubleshooting this error by checking the permissions of the images. We could see that the permissions were not readable/writable.
So, updated the permissions of the images using the command:
chmod -R 777 imagesLastly, this error fixed after changing the permissions of images.
[Need any assistance with ImageMagick? – We’ll help you]
Conclusion
In short, ImageMagick is used to manipulate the digital images. Today, we saw how our Support Engineers install ImageMagick and fix its errors.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
GET STARTED
var google_conversion_label = "owonCMyG5nEQ0aD71QM";
ImageMagick is a free open source simple software suite for any kind of image manipulation that is used for creating, editing, converting, displaying image files.
It can able to read and write over 200 image files such as JPEG, GIF, PNG, TIFF, and Photo CD image formats and it is also used for thumbnail or captcha generation. It also includes command-line options for creating transparent or animated gif image formats and many more features like resize, sharpen, rotate or add special effects to an image.
To use the ImageMagick tool with PHP or Perl programming language, you will need to install ImageMagick with the Imagick PHP extension for PHP and ImageMagick-Perl extension for Perl.
Imagick is a simple PHP extension for creating and modifying images using the ImageMagick API program. There is a confusion in name, as people think that ImageMagick and Imagick both are the same, but you can use ImageMagick without Imagick extension but you need both installed on your machine to use and run it.
Installing ImageMagick from Repository
First, install following prerequisite php-pear, php-devel and gcc packages to compile the Imagick PHP extension.
# yum install php-pear php-devel gccOnce you’ve installed php-pear, php-devel, and gcc packages, you may now install ImageMagick software for PHP and Perl support using yum command.
# yum install ImageMagick ImageMagick-devel ImageMagick-perlIMPORTANT: ImageMagick is not available in CentOS/RHEL 8, and it has been replaced with GraphicsMagick instead, which is a fork of ImageMagick.
To install GraphicsMagick on CentOS/RHEL 8, run the following command.
# dnf info GraphicsMagick # dnf install GraphicsMagick GraphicsMagick-devel GraphicsMagick-perlNext, verify that ImageMagick has been installed on your system by checking its version.
# convert --version Version: ImageMagick 6.7.8-9 2019-02-01 Q16 //www.imagemagick.org Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC Features: OpenMPCentOS/RHEL 8 users, can run the following command to verify the version of GraphicsMagick installed on the system.
# gm version GraphicsMagick 1.3.33 2019-07-20 Q16 //www.GraphicsMagick.org/ Copyright (C) 2002-2019 GraphicsMagick Group. Additional copyrights and licenses apply to this software. See //www.GraphicsMagick.org/www/Copyright.html for details.Installing ImageMagick 7 from Source Code
To install ImageMagick from source, you need a proper development environment with a compiler and related development tools. If you don’t have the required packages on your system, install development tools as shown:
# yum 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-develNow, download the latest version of the ImageMagick source code using the following wget command and extract it.
# wget //www.imagemagick.org/download/ImageMagick.tar.gz # tar xvzf ImageMagick.tar.gzConfigure and compile the ImageMagick source code. Depending on your server hardware specs, this may take some time to finish.
# cd ImageMagick* # ./configure # make # make installVerify that the ImageMagick compile and install were successful.
# magick -version Version: ImageMagick 7.0.8-28 Q16 x86_64 2019-02-19 //imagemagick.org Copyright: © 1999-2019 ImageMagick Studio LLC License: //imagemagick.org/script/license.php Features: Cipher DPC HDRI OpenMP Delegates (built-in): bzlib djvu fontconfig freetype jng jpeg lzma openexr pangocairo png tiff wmf x xml zlibInstall Imagick PHP Extension
Next, compile the Imagick for PHP extension. To do, simply run the following ‘pecl‘ command. It will install ImageMagick and imagick PHP extension module ‘imagick.so‘ under /usr/lib/php/modules directory. If you are using a 64-bit system, the module directory path would be /usr/lib64/php/modules.
Note: It will ask you to provide Imagemagick installation prefix, simply hit enter to auto-detect.
Now, add the ‘imagick.so‘ extension to ‘/etc/php.ini‘ file.
echo extension=imagick.so >> /etc/php.iniNext, restart Apache webserver.
# service httpd restartVerify the Imagick PHP extension by running the following command. You will see the Imagick extension similar to below.
# php -m | grep imagick imagickInstall GMagick PHP Extension
Run the following commands to compile and install GMagick PHP Extension.
# cd /usr/local/src # wget //pecl.php.net/get/gmagick # tar xfvz gmagick # cd gmagick-* # phpize # ./configure # make # make installNow, add the ‘gmagick.so‘ extension to ‘/etc/php.ini‘ file.
# echo extension=gmagick.so >> /etc/php.iniNext, restart the Apache webserver.
# systemctl restart httpdVerify gmagick PHP extension by running the following command.
# php -m | grep gmagick gmagickAlternatively, you can create a file called ‘phpinfo.php‘ under website root directory (ex: /var/www/html/).
# vi /var/www/html/phpinfo.phpAdd the following code.
<?php phpinfo (); ?>Open your favorite web browser and type ‘//localhost/phpinfo.php‘ or ‘//ip-addresss/phpinfo.php‘ and verify the extension.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.