How to Install ImageMagick on Ubuntu 24.04, 22.04 or 20.04

ImageMagick is a feature-rich, command-line tool designed for editing, converting, and managing images across many formats. Its versatility and power make it a go-to solution for developers, photographers, and graphic designers.

Below are key highlights that set ImageMagick apart:

  • Versatile Image Processing: Batch efficiently processes images, automating tasks that would otherwise require extensive manual effort.
  • Extensive Format Support: Handles over 200 image formats, offering unparalleled image conversion and manipulation flexibility.
  • Robust Conversion Capabilities: Convert images between formats without losing quality, ensuring your images are ready for any platform or device.
  • Powerful Image Editing: With simple command-line instructions, you can perform complex editing tasks such as cropping, resizing, and color adjustments.
  • Advanced Features: Includes capabilities for creating composite images, adding text, or applying advanced filtering effects.
  • Scriptable Automation: Automate repetitive tasks by scripting with ImageMagick, saving time and reducing human error.
  • Resource Efficiency: Optimized for performance, it works well on servers and with batch processing, ensuring minimal resource usage.
  • Open Source and Cross-Platform: It is free to use and modify and runs on Linux, Windows, and macOS, making it widely accessible.

Now that we have covered the key highlights for users who may be new to ImageMagick let’s demonstrate two methods for installing it on your system.

Method 1: Install ImageMagick via APT

Update Ubuntu Before ImageMagick Installation

The first step in installing ImageMagick on Ubuntu is ensuring your system is up to date. This will ensure that you have the latest security updates and that your system is compatible with ImageMagick.

To update your system, open the terminal and run the following command:

sudo apt update && sudo apt upgrade

Install Support Libraries For ImageMagick

ImageMagick relies on several libraries to function correctly. To install these libraries, run the following command:

sudo apt install libpng-dev libjpeg-dev libtiff-dev

Install ImageMagick on Ubuntu via APT Command

The easiest and most recommended way for the average user to install ImageMagick is through the APT package manager. If this works correctly, stick with it; do not try to install the source method, as it will complicate things more than you need.

For the APT method, install ImageMagick using the following command:

sudo apt install imagemagick

And that is it; for alternative installation methods, check out the next section on how to compile ImageMagick.

Method 2: Install ImageMagick via Source

The alternate installation method involves cloning the ImageMagick GIT repository and compiling the application. This option is not suitable for the average user. However, follow these steps to utilize the source version to access the latest or a specific older release.

Ensure Git is Installed

Before proceeding with this installation method, you must ensure that GIT is installed on your system. You can check this by running the following command in the terminal:

git --version

The command shows the GIT version installed on your system. If you don’t have GIT, run the following command to install it:

sudo apt install git

Clone ImageMagick Git Repository

Open the terminal, navigate to the desired location to store the cloned repository, and then run the following command to clone the repository:

git clone

If you prefer, you can specify the location of the cloned repository to “/usr/local/src/ImageMagick” by using the following command:

git clone /usr/local/src/ImageMagick

It’s important to note that depending on your GIT/user privilege configuration, you may use the sudo command while cloning the repository:

sudo git clone /usr/local/src/ImageMagick

Navigate to ImageMagick Source Directory

Clone the ImageMagick repository, then navigate to the directory where you cloned it. The location might differ based on your specific setup, but here are the general steps:

cd ImageMagick

Or if you cloned it to “/usr/local/src/ImageMagick.”

cd /usr/local/src/ImageMagick

Install Required Packages to Compile ImageMagick

To continue the installation process, you must install the dependencies required to compile ImageMagick. The dependencies include various libraries and tools necessary for the compilation process. You can install the dependencies by running the following command in the terminal:

sudo apt install build-essential libltdl-dev libjpeg-dev libpng-dev libtiff-dev libgif-dev libfreetype6-dev liblcms2-dev libxml2-dev

Prepare the ImageMagick Source

With the dependencies installed, the next step is to run the ./configure command to prepare the ImageMagick source for compilation:


This command will check for any dependencies or configurations required to compile ImageMagick. If any dependencies or configurations are missing, the ./configure command will display an error message. In this case, you must install the missing dependencies or resolve the configuration issues before proceeding with the next step.

See also
How to Install Pale Moon on Ubuntu 22.04 or 20.04

Optional: Configure ImageMagick with Modules

Advanced users who want more functionality from ImageMagick should build the application using the –with-modules option. This option allows the installation of extra optional features and modules, enhancing the ImageMagick experience.

To use this option, include it in the ./configure command:

./configure --with-modules
Output of ImageMagick configure script on Ubuntu 24.04, 22.04, and 20.04.
Checking prerequisites for ImageMagick installation.

Note: Including “./configure –with-modules”, you can ensure access to the full range of features and functionality ImageMagick offers.

Build ImageMagick Environment

After building and configuring the environment, compile ImageMagick using the make command:

'Make' command execution for ImageMagick on Ubuntu 24.04, 22.04, and 20.04.
Building ImageMagick from source on Ubuntu.

This command will compile the ImageMagick source code into a usable application. The compilation process may take several minutes, depending on your system specifications. After the compilation is complete, you can proceed with the next step.

Install ImageMagick via Compiled Binary

With the source code compiled, the next step is to run the installation command. This will install ImageMagick on your Ubuntu system:

sudo make install
Finalizing ImageMagick installation with 'make install' on Ubuntu 24.04, 22.04, and 20.04.
Completing the ImageMagick installation process.

Configure Dynamic Linker Run-Time for ImageMagick

After installing ImageMagick, configure the dynamic linker run-time bindings as the final step. This action ensures your system can find and use the ImageMagick libraries during run-time:

sudo ldconfig /usr/local/lib

This command will configure the dynamic linker run-time bindings, making ImageMagick accessible and usable on your system.

After running this command, you should be able to use ImageMagick without any issues; failure may result in the following error in your terminal:

magick: error while loading shared libraries: cannot open shared object file: No such file or directory
LD configuration for ImageMagick library issues fix on Ubuntu 24.04, 22.04, and 20.04.
Configuring libraries for ImageMagick on Ubuntu.

Remember that if you upgrade or reinstall ImageMagick in the future, you might need to reconfigure the dynamic linker run-time bindings. If that happens, follow the steps above to reconfigure them.

Verify ImageMagick Installation

Once you have installed ImageMagick, you can verify the installation by running the following command.

magick --version

Example output:

Version: ImageMagick x.x.x

Examples of ImageMagick Commands

Convert an Image Format with ImageMagick

ImageMagick can also convert an image from one format to another. For example, you can use the following command to convert a JPG image to PNG.

convert input.jpg output.png

Create a Thumbnail with ImageMagick

Use ImageMagick to create a thumbnail from an image. The command is:

convert input.png -thumbnail 200x200 output.png

This command will create a 200×200 thumbnail from the image “input.png” and save the result as “output.png.”

Resize an Image with ImageMagick

You can use ImageMagick to resize an image to a specific dimension. The command for this is.

convert input.png -resize 200x200 output.png

This will resize the image “input.png” to a 200×200 image and save the result as “output.png.”

Add Text to an Image with ImageMagick

You can add text to an image using ImageMagick. The command for this is.

convert input.png -font Arial -pointsize 36 -fill black -draw "text 20,50 'Hello World'" output.png

This command adds the text “Hello World” to the image “input.png” using the Arial font and a 36-point font size. The text has a black fill and sits at the position (20,50). The system saves the result as “output.png.”


Throughout this guide, we walked through the steps to install ImageMagick on Ubuntu versions 24.04, 22.04, and 20.04 LTS, showcasing the simplicity and versatility of managing images directly from your command line. Whether you’re converting formats, editing, or automating tasks, ImageMagick is an indispensable tool for anyone dealing with digital images.

Useful Links

Here are some valuable links related to using ImageMagick on an Ubuntu system:

  • ImageMagick GitHub Repository: Visit the official ImageMagick GitHub repository to access the source code, report issues, and contribute to the development.
  • ImageMagick Official Website: Explore the official ImageMagick website for detailed information about the software, its features, and the latest updates.
  • ImageMagick Discussions: Join the discussions on GitHub to ask questions, share solutions, and get support from the ImageMagick community.

These links provide additional information and resources to help you make the most out of ImageMagick on your Ubuntu system.

Leave a Comment

TOC Index
Your Mastodon Instance
Share to...