How to Install ImageMagick on Rocky Linux 9

ImageMagick is a free, open-source application that can be installed as either a binary distribution or source code. It can convert, read, write, and process raster images. ImageMagick also has versions available across all major platforms, including Android, BSD, Linux, Windows, Mac OSX, iOS, and many others. This makes it a versatile tool for those looking to manipulate images for various projects. Whether you are a graphic designer needing to crop and resize an image for a website or a developer wanting to create an avatar for a user profile, ImageMagick can easily handle the task. And because it is open-source, an active community of users is always ready to help out or contribute new features.

The following tutorial will teach you how to install ImageMagick on Rocky Linux 9 workstation desktop or headless server using the DNF or Source installation method.

Update Rocky Linux

First, update your operating system to ensure all existing packages are up to date.

sudo dnf upgrade --refresh

Method 1 – Install ImageMagick – Default Method

By default, ImageMagick is featured in the appstream rpm. This is the recommended way to install the application, given it is almost always up to date with the latest version.

In your terminal, use the following command to begin the installation.



sudo dnf install ImageMagick -y

Alternatively, you can install ImageMagick’s development branch if you require it.

 sudo dnf install ImageMagick-devel

Ensure you use the capital letters in the above commands; if you use all lowercase, the command will not work.

Once the installation has been completed, verify the installation by checking the build and version.

convert --version

Example output:

How to Install ImageMagick on Rocky Linux 9

Method 2 – Install ImageMagick – Compile Method

This installation choice isn’t recommended for the average user. However, follow the steps below for those wanting to use the source version.

Firstly, make sure you have GIT installed.



sudo dnf install git -y

Second, enable the CRB repository.

sudo dnf config-manager --set-enabled crb

Next, install EPEL using the following (dnf) terminal command.

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

Now clone the GIT source.

sudo git clone https://github.com/ImageMagick/ImageMagick.git /usr/local/src/ImageMagick

Note, depending on how you set your GIT up; you may need to use or remove 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 libtool -y

Lastly, install the development tools package.

sudo dnf groupinstall "Development Tools" -y

Now, optionally but recommended, change the directory permission to your own; this prevents having to use the sudo command and is better for overall security. Skip this if you are using a root account only.

Replace the user:user with your username:username, or username:group such as root.

Example with my username:

sudo chown -R joshua:joshua /usr/local/src/ImageMagick

You will now need to use the ./configure command.

./configure

Advanced users want more from ImageMagick, so using –with-modules is a recommended option to add.



./configure --with-modules

Now that you have created and configured the environment, it is time to compile it with the command make.

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 six or at least 4 to 5 to increase speed.

Example only:

make -j 6

After compiling the source code, 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:

How to Install ImageMagick on Rocky Linux 9

Updating ImageMagick from Source

If you installed ImageMagick from the source using git, repeat the installation process after pulling any new changes from the source GitHub using the following terminal command.

git pull

Once imported, repeat the process to install the update. Remember, depending on your installation setup; you may need to use the sudo command with the git pull.

Test & Verify ImageMagick

The quickest way to test if ImageMagick is working is to use the convert logo command.

convert logo: logo.gif

Then list the directory using the ls command.



ls

Example:

How to Install ImageMagick on Rocky Linux 9

Example Terminal Commands

Below is a table of commands and tools that can be used with ImageMagick:

CommandDescription
animateDisplay an image sequence as an animation.
compareAnalyze two images, and visualize mathematical differences between them.
compositeCompose one image over another with variable transparency to create a composite image.
conjureInterpret and execute scripts written in MSL, the Magick Scripting Language.
convertConvert images from one file format to another. This tool can also blur, crop, despeckle, dither, and otherwise modify the content of an image.
displayA simple image viewer.
identifyDisplay the image dimensions, quality, and other image metadata.
importCapture the screen to an image file.
mogrifyModify an image. Similar to converting, but overwrites the original image.
montageCreate an image composed of smaller images. This command can create a single image containing thumbnails of many images.
streamProcess 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

ImageMagick is a versatile, open-source image processing tool that can handle many tasks. ImageMagick can help you do the job, whether a graphic designer or developer. And because it is open-source, an active community of users is always ready to help out or contribute new features. So if you need an image processing tool, look no further than ImageMagick.

For additional information, please visit the official ImageMagick website.


Not what you were looking for? Try searching for additional tutorials.

Leave a Comment