How to Install ImageMagick on Ubuntu 22.04 or 20.04

ImageMagick, when you install it on Ubuntu 22.04 Jammy Jellyfish or its older stable release Ubuntu 20.04 Focal Fossa, provides a powerful, open-source platform for image creation, editing, and manipulation. Esteemed by graphic designers, photographers, and web developers alike, this software boasts many features, enabling users to tackle a wide range of image-related tasks, from basic adjustments to intricate special effects.

Key Attributes of ImageMagick:

  • Versatile Image Editing: Whether it’s resizing, cropping, or applying intricate effects, ImageMagick has the tools to transform your images.
  • Broad Format Support: With compatibility spanning across formats like JPEG, PNG, GIF, and TIFF, ImageMagick ensures seamless image processing.
  • Command-Line Mastery: The software’s command-line interface facilitates automation, streamlining repetitive image tasks.
  • Efficient Batch Processing: Tackle large projects head-on with ImageMagick’s capability to process multiple images simultaneously.
  • Developer-Friendly Scripting: Integrate ImageMagick into scripts for automated, developer-centric image operations.
  • Open-Source Advantage: Being open-source, ImageMagick is free and benefits from collaborative enhancements.

If you want to integrate this powerful tool into your Ubuntu system, the following guide will explain how to install ImageMagick on Ubuntu 22.04 Jammy Jellyfish or its older stable release, Ubuntu 20.04 Focal Fossa. You can install it using the default APT repository or compile it from the source.

Install ImageMagick on Ubuntu 22.04 or 20.04 via APT

Step 1: 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

Step 2: 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

Step 3: Install ImageMagick on Ubuntu 22.04 or 20.04 via APT Command

The easiest and most recommended way to install it is using the APT package manager for the average user. If this works correctly, stick with it and 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.

Install ImageMagick on Ubuntu 22.04 or 20.04 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.

Before proceeding with this installation method, you must ensure that you have GIT 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

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 https://github.com/ImageMagick/ImageMagick.git

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

git clone https://github.com/ImageMagick/ImageMagick.git /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 https://github.com/ImageMagick/ImageMagick.git /usr/local/src/ImageMagick

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

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

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

./configure

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

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
Screenshot of the configure script output for ImageMagick compilation on Ubuntu 22.04 or 20.04.Pin
Output display of the configure script during ImageMagick’s compilation process on Ubuntu 22.04 or 20.04.

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

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

make
Screenshot of the 'make' command output for ImageMagick compilation on Ubuntu 22.04 or 20.04.Pin
Display of the ‘make’ command results during the ImageMagick compilation process on Ubuntu 22.04 or 20.04.

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.

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
Screenshot of the 'make install' command output for ImageMagick compilation on Ubuntu 22.04 or 20.04.Pin
Results of the ‘make install’ command during ImageMagick’s compilation on Ubuntu 22.04 or 20.04.

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: libMagickCore-7.Q16HDRI.so.10: cannot open shared object file: No such file or directory
Screenshot of the LD configuration for library fixes during ImageMagick's manual compilation on Ubuntu 22.04 or 20.04.Pin
Configuration settings for addressing library issues during manual compilation of ImageMagick on Ubuntu 22.04 or 20.04.

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.

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 on Ubuntu 22.04 or 20.04

Convert an Image Format with ImageMagick on Ubuntu

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 on Ubuntu

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 on Ubuntu

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 on Ubuntu

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.”

Conclusion

In conclusion, you can install ImageMagick on Ubuntu by using the terminal or cloning the ImageMagick GIT repository. The first method is quicker and better for the average user, while the second is more complex and lets you choose either the latest or a specific older release. No matter which method you choose, follow the steps carefully to ensure successful installation.

For additional information, please visit the official ImageMagick website.

Share to...