CentOSRHEL Based

How To Install ImageMagick on CentOS Stream 9

Install ImageMagick on CentOS Stream 9

In this tutorial, we will show you how to install ImageMagick on CentOS Stream 9. ImageMagick is a powerful open-source software suite for creating, editing, and converting images. It supports over 200 image formats, including PNG, JPEG, GIF, TIFF, and more. With ImageMagick, you can resize, crop, rotate, and apply various effects to images. It’s widely used by web developers, graphic designers, photographers, and anyone who needs to manipulate images programmatically.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the ImageMagick on CentOS Stream 9.


  • A server running one of the following operating systems: CentOS Stream 9.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection.
  • You’ll need administrative privileges or root access on your CentOS Stream 9 system. If you don’t have them, reach out to your system administrator.

Install ImageMagick on CentOS Stream 9

Step 1. Keeping your system up to date is crucial for security and compatibility. Execute the following command to update your system:

sudo dnf clean all
sudo dnf update
sudo dnf install epel-release

This command will update all the installed packages on your CentOS system.

Step 2. Installing Dependencies.

Now install the required dependencies:

sudo dnf install gcc gcc-c++ make automake autoconf libtool libjpeg-devel libpng-devel libtiff-devel libxml2-devel

These dependencies are necessary for compiling ImageMagick from source code, which we’ll cover later in the guide.

Step 3. Installing ImageMagick on CentOS Stream 9.

  • Installing ImageMagick from Repository

Install the ImageMagick package using the following command below:

sudo dnf install ImageMagick

Verify the installation by checking the ImageMagick version:

magick --version
  • Installing ImageMagick from Source

While installing from the official repositories is convenient, some users may prefer to install ImageMagick from source code. This method offers more control over the installation process and ensures you have the latest version of ImageMagick with all the desired features and optimizations.

Visit the official ImageMagick website and download the latest source code. You can use the wget command to download the source code directly:

wget https://download.imagemagick.org/archive/ImageMagick-7.1.1-29.tar.gz

Extract the downloaded source code:

tar xvzf ImageMagick-7.1.1-29.tar.gz

Navigate to the extracted directory and run the configure script with the desired options:

cd ImageMagick-7.1.1-29
./configure --prefix=/usr/local --with-modules --enable-shared --disable-static

Compile the source code:


Install the compiled ImageMagick:

sudo make install

After the installation is complete, verify the installed version:

/usr/local/bin/magick --version

Step 3. Installing the PHP ImageMagick Extension.

If you’re a web developer working with PHP, you’ll likely need to install the ImageMagick PHP extension to integrate ImageMagick functionality into your PHP applications. Install PHP development packages:

sudo dnf install php-devel

Install the ImageMagick PHP extension:

sudo pecl install imagick

Step 4. Configure PHP to load the extension.

Open your PHP configuration file (/etc/php.d/imagick.ini or /etc/php.ini) and add the following line:


Verify successful installation of the PHP ImageMagick extension:

echo "ImageMagick is installed: " . (extension_loaded('imagick') ? 'Yes' : 'No');

Run the file:

php test.php

If the output is “ImageMagick is installed: Yes”, the extension is installed and loaded correctly.

Here’s a basic example of using the ImageMagick PHP extension:

$image = new Imagick('example.jpg');
$image->thumbnailImage(200, 0);

This code loads an image (example.jpg), creates a thumbnail with a width of 200 pixels, and saves it as thumbnail.jpg.

Congratulations! You have successfully installed ImageMagick. Thanks for using this tutorial to install ImageMagick on CentOS Stream 9. For additional help or useful information, we recommend you check the official ImageMagick website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button