How to Install ImageMagick on Rocky Linux 9/8

ImageMagick is a robust and versatile software suite for creating, editing, and converting bitmap images. It supports various image formats and provides powerful command-line tools for performing complex image manipulations. ImageMagick is a go-to solution for developers and graphic designers who need to automate image processing tasks.

To install ImageMagick on Rocky Linux 9 or 8, you have two main options: using the DNF package manager to install from the default repository or compiling the latest version from the source. Both methods ensure you have a powerful toolset for all your image processing needs, with the latter providing the most up-to-date features and fixes.

Method 1: Install ImageMagick via Rocky Linux Appstream

Update Rocky Linux System Packages Before ImageMagick Installation

Let’s begin the installation procedure by updating your system packages. An up-to-date system ensures you have the latest bug fixes, security patches, and software updates. This enhances the overall performance and security of your Rocky Linux system.

Run the following command in your terminal to update your system packages:

sudo dnf upgrade --refresh

This command may require some time to complete based on the status of your installed packages. It would be best to upgrade all packages successfully before moving to the next step.

Import EPEL 9 or EPEL 8 for Rocky Linux

To install ImageMagick, we first need to import the EPEL (Extra Packages for Enterprise Linux) repository. EPEL is a Fedora Special Interest Group that creates, maintains, and manages a high-quality set of additional packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS, and Rocky Linux.

Importing EPEL for Rocky Linux 9

First, we need to enable the CodeReady Builder (CRB) repository. CRB is a channel that provides developers additional packages, including debug and development packages.

Execute the following command in your terminal to enable the CRB:

sudo dnf config-manager --set-enabled crb

Next, we proceed to install the EPEL repository on your system. The installation is done via the terminal with the help of the dnf command.

Use the following command to import EPEL for Rocky Linux 9:

sudo dnf install \
    https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
    https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm

After running the command above, the system will fetch and install the specified EPEL repositories.

Importing EPEL for Rocky Linux 8

Users operating on Rocky Linux 8 need to follow a process similar to Rocky Linux 9. The only difference lies in the repository URLs.

Here’s the command you need to run for importing EPEL on Rocky Linux 8:

sudo dnf install \
    https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
    https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-8.noarch.rpm

By running this command, your system will fetch and install the EPEL repositories pertinent to Rocky Linux 8.

Install ImageMagick via DNF Command

After successfully importing the EPEL repository, we can install ImageMagick on your system.

Now, execute the following command to install ImageMagick:

sudo dnf install ImageMagick

This command instructs the DNF package manager to fetch the latest version of ImageMagick from the enabled repositories and any dependencies required.

Verifying the Installation of ImageMagick

After completing the installation process, you should check if you have successfully installed ImageMagick and if it’s ready for use. To check the installed version of ImageMagick on your system, you can use the convert --version command as shown below:

convert --version

The command displays the ImageMagick version installed on your system, verifying the successful software installation using EPEL.

Method 2: Install ImageMagick via Source

In certain scenarios, you may need to install ImageMagick directly from the source. This approach offers the flexibility to select a specific version or tailor the build options to your needs. This process involves a series of steps, which we’ll walk through in detail.

Install Initial Build Dependencies For ImageMagick

For the successful compilation of ImageMagick from the source code, specific dependencies are necessary. These include gcc, clang, and make, which are instrumental in the build process. You can install these using the following command in your terminal:

sudo dnf install gcc clang make

Download ImageMagick Source Code

Next, you’ll need to obtain the ImageMagick source code. The official GitHub repository of ImageMagick hosts the source code for all versions of the software. Please note that the following command serves as an example. Replace the x.x.x-x part of the URL with the version number of ImageMagick you wish to install.

wget https://github.com/ImageMagick/ImageMagick/archive/refs/tags/x.x.x-x.tar.gz

Extract the ImageMagick Archive

After downloading the ImageMagick archive, you need to extract its contents. The tar command below serves this purpose. Replace <imagemagick archive> with the name of the downloaded file.

tar xvzf <imagemagick archive>.tar.gz

Move the Extracted ImageMagick Directory

To organize the file structure better, moving the extracted ImageMagick directory to a more suitable location is recommended. Here, we’re using /usr/local/share for this purpose, but you can choose a different location if you prefer.

sudo mv ImageMagick-*.* /usr/local/share/imagemagick

Navigate to the ImageMagick Directory

Next, navigate into the ImageMagick directory in /usr/local/share/imagemagick using the cd command:

cd /usr/local/share/imagemagick

Configure the Build For ImageMagick

Within this directory, initiate the configuration for the build process. This is done using the ./configure command:

./configure

Build and Install ImageMagick

After successful configuration, the next step is to build and install ImageMagick. This is a two-step process executed with the make and sudo make install commands:

make
sudo make install

Update the Shared Library Cache for ImageMagick

The final step involves updating the system’s shared library cache. This step ensures that the system recognizes the newly installed libraries with ImageMagick. The ldconfig command serves this purpose:

sudo ldconfig /usr/local/share/imagemagick

Verify the Installation of ImageMagick

With all the steps completed, the last thing to do is verify ImageMagick’s successful installation. The convert --version command will display the installed version of ImageMagick, confirming its successful installation:

convert --version

Closing Thoughts

In this guide, we’ve explored the essential steps to install ImageMagick on Rocky Linux, both for version 9 and the Enterprise 8 series. ImageMagick is a powerful tool for handling various image formats and performing extensive image processing tasks. With this installation, your Linux system is now equipped to leverage ImageMagick’s capabilities. Start with the basic commands provided and gradually explore its extensive options to fine-tune your image manipulations.

Leave a Comment