ImageMagick is an open-source, free, and powerful application used for creating, editing, and converting images into various formats. Some of the images formats it supports include PNG, GIF, JPEG, PDF, EXR, WebP, and TIFF. Using ImageMagick, you can resize, rotate, crop, distort, flip, modify image colors, and apply a number of effects. You can also add text and different shapes to images.
In this post, we will cover how to install ImageMagick on CentOS using two different methods:
• Installation via Repository
• Installation via Source
Installation of ImageMagick via Repository
ImageMagick is available in the Yum default repositories. In this method, we will install ImageMagick via the Yum repository. Follow the below steps for the installation procedure:
1. First, install some prerequisites packages in your system using the command below:
$ sudo yum install gcc php-devel php-pear
If prompted, provide the sudo password, and then it will start installing all the prerequisites. Once the prerequisites are installed, move on to the next step.
2. Now you can install ImageMagick on your system. Use the command below to do so:
$ sudo yum install ImageMagick ImageMagick-devel ImageMagick-perl
If prompted, provide the sudo password. After this, the installation of ImageMagick will be started on your system.
Once ImageMagick is installed, you can verify it by running the command below:
$ convert --version
The result below shows that ImageMagick version 6.9.10-86 has been installed on our machine.
Installation of ImageMagick via Source
In this method, we will install ImageMagick via source code. Follow the below steps for the installation procedure:
1. First, install some development tools on your system using the command below:
$ sudo yum groupinstall 'Development Tools'
Then install some other packages using the command below:
$ sudo yum install freetype-devel libjpeg-devel jasper-devel libpng-devel bzip2-devel libtiff-devel giflib-devel zlib-devel ghostscript-devel djvulibre-devel libwmf-devel librsvg2-devel libtool-ltdl-devel libX11-devel lcms-devel libXext-devel libXt-devel libxml2-devel OpenEXR-devel php-devel
2. Now, download ImageMagick source code by running this command in the Terminal:
$ wget https://www.imagemagick.org/download/ImageMagick.tar.gz
The downloaded file will be saved in your current directory as ImageMagick.tar.gz.
3. Extract the archive by running the command below in the Terminal:
$ tar xvzf ImageMagick.tar.gz
You can find the extracted archive in your current directory as ImageMagick-7.1.0-4.
4. Move inside the extracted archive directory and run the configure script using the commands below:
$ cd ImageMagick-7.1.0-4/
$ sudo ./configure
This command will check for all the dependencies that are required to build and install the package.
5. Now, you will need to build the package by running this command:
$ sudo make
6. Then use this command to install the package:
$ sudo make install
Now it will take a while, after which ImageMagick will be installed on your machine.
To verify the installation of ImageMagick, run this command:
$ magick --version
The result below shows that ImageMagick version 7.1.0-4 has been installed on our machine.
If in case you need to uninstall ImageMagick from your system, you can do so using the methods below:
If ImageMagick has been installed via repository, it can be uninstalled using the command below:
$ sudo yum remove imagemagick
It will remove ImageMagick and its dependencies from your system.
If ImageMagick has been installed via source code, it can be uninstalled using the commands below:
Move inside the ImageMagick directory using the command below:
$ cd ImageMagick-7.1.0-4/
Then uninstall it as follows:
$ sudo make uninstall
In this post, we covered how to install ImageMagick on the CentOS machine via two different methods. We also covered how to uninstall ImageMagick in case you want to remove it from your machine.