ImageMagick is a free, open-source application installed as a binary distribution or as a source code. ImageMagick can convert, read, write and process raster images. ImageMagick is also available across all major platforms, including Android, BSD, Linux, Windows, Mac OSX, iOS, and many others.
In the following tutorial, you will learn how to install ImageMagick on Rocky Linux 8 using the DNF or Source installation method.
Table of Contents
Prerequisites
- Recommended OS: Rocky Linux 8.+.
- User account: A user account with sudo or root access.
Update Operating System
Update your Rocky Linux operating system to make sure all existing packages are up to date:
sudo dnf upgrade --refresh -y
The tutorial will be using the sudo command and assuming you have sudo status.
To verify sudo status on your account:
sudo whoami
Example output showing sudo status:
[joshua@rockylinux ~]$ sudo whoami
root
To set up an existing or new sudo account, visit our tutorial on How to Add a User to Sudoers on Rocky Linux.
To use the root account, use the following command with the root password to log in.
su
Option 1 – Install ImageMagick from DNF
The easiest and most recommended way to install is using the DNF package manager for the average user. The issue is that the Rocky Linux 8 app stream does not come with the package, so you will need to install the EPEL repository and enable “PowerTools.”
First, install the EPEL repository using the following command:
sudo dnf install epel-release -y
Next, enable the PowerTools repository:
sudo dnf config-manager --set-enabled powertools
Now install ImageMagick using the following command:
sudo dnf install ImageMagick ImageMagick-devel
Example output:
TYPE Y then press the ENTER KEY to proceed and complete the installation.
Once the installation has been completed, verify the install by checking the build and version.
convert --version
Example output:
Updates will be handled using the standard system update command.
sudo dnf upgrade --refresh -y
To remove ImageMagick from your system, use the following command.
sudo dnf autoremove ImageMagick ImageMagick-devel -y
Note, this will also remove all unused dependencies for complete removal.
Option 2 – Install ImageMagick from Source
This installation choice isn’t recommended for the average user. However, for those wanting to use the source version, follow the steps below.
Firstly, make sure you have GIT installed:
sudo dnf install git -y
Now clone the GIT:
sudo git clone https://github.com/ImageMagick/ImageMagick.git /usr/local/src/ImageMagick
Note, depending on how you set your GIT up, and you may need to use the sudo command.
Next, CD into the directory:
cd /usr/local/src/ImageMagick
Now install the dependencies required:
sudo dnf install make automake cmake gcc libtool-ltdl-devel
You will now need to use the ./configure command:
sudo ./configure
Advanced users want more from ImageMagick it is recommended to use –with-modules build:
sudo ./configure --with-modules
Now that you have built and configured the environment, it is time to compile it with the command make.
sudo make
A handy trick is to specify the -j <number of cpu> as this can significantly increase compiling speed if you have a powerful server.
For example, the LinuxCapable server has 6 CPUs, and I can use all 6 or at least use 4 to 5 to increase speed.
Example only:
sudo make -j 6
After compiling the source code, now run the installation command in your terminal:
sudo make install
After the installation, you need to configure the dynamic linker run-time bindings:
sudo ldconfig /usr/local/lib
Now verify the installation and build:
magick --version
Example output:
Updating ImageMagick from Source
If you installed ImageMagick from source using git, re-peat the installation process after you have pulled any new changes from the sources Github using the following terminal command:
sudo git pull
Once imported, repeat the process to install the update.
Test & Verify ImageMagick
The quickest way to test if ImageMagick is working is to use the convert logo command as follows:
convert logo: logo.gif
If you installed ImageMagick using either using DNF repository or the ImageMagick source, the test logo.gif would be located in the home directory.
First CD to your home directory, replacing username with your own:
cd /home/username/
Then list the directory using the ls command:
ls
Example:
Example Terminal Commands
Below is a table of commands and tools that can be used with ImageMagick:
Command | Description |
---|---|
animate | Display an image sequence as an animation. |
compare | Analyze two images, and visualize mathematical differences between them. |
composite | Compose one image over another with variable transparency to create a composite image. |
conjure | Interpret and execute scripts written in MSL, the Magick Scripting Language. |
convert | Convert images from one file format to another. This tool can also blur, crop, despeckle, dither, and otherwise modify the content of an image. |
display | A simple image viewer. |
identify | Display the image dimensions, quality, and other image metadata. |
import | Capture the screen to an image file. |
mogrify | Modify an image. Similar to converting, but overwrites the original image. |
montage | Create an image composed of smaller images. This command can create a single image containing thumbnails of many images. |
stream | Process image data and store it in a file as it is being streamed from an input source. Useful for situations with slow data streams or huge images whose data processing should begin before the entire image is stored. |
Commands and Conclusion
In the tutorial, you have learned two ways to install ImageMagick on Rocky Linux 8. Overall, ImageMagick is still quite popular, especially around WordPress websites and plugins, and is a tried and tested option for displaying, creating, converting, modifying, and editing raster images.
For additional information, please visit the official ImageMagick website.