How to Install ImageMagick on Ubuntu (26.04, 24.04, 22.04)

Last updated Saturday, February 14, 2026 1:39 pm Joshua James 10 min read

ImageMagick lets you resize, crop, convert, and batch-process images directly from the command line. This guide covers how to install ImageMagick on Ubuntu through the APT package manager or by compiling from source. Common use cases include converting hundreds of JPG files to PNG for web optimization, generating thumbnails automatically for galleries, and adding watermarks to protect images. By the end of this guide, you will have a working ImageMagick installation ready for format conversion, batch resizing, and automated image transformation tasks.

Install ImageMagick on Ubuntu

Ubuntu offers multiple ways to install ImageMagick. The APT method provides a stable, distribution-tested version with automatic updates, while compiling from source gives you access to the latest features and bug fixes.

MethodChannelVersionUpdatesBest For
APT PackageOfficial reposDistribution defaultAutomatic via apt upgradeMost users who want stable packages with automatic updates
Compile from SourceGitHub ReleasesLatest stableManual recompilationDevelopers who need the latest features or custom builds

The commands in this guide apply to Ubuntu 26.04, 24.04, and 22.04. The APT package version varies by release, but installation steps remain identical across all three LTS versions.

Method 1: Install ImageMagick via APT

The APT method installs ImageMagick 6.x from Ubuntu’s official repositories. You get a stable version with automatic security updates and minimal maintenance requirements.

Update your package lists and install ImageMagick along with common image format libraries:

sudo apt update && sudo apt install imagemagick libpng-dev libjpeg-dev libtiff-dev

Confirm ImageMagick installed correctly by checking the version:

convert --version

You should see output similar to:

Version: ImageMagick 6.9.12-98 Q16 x86_64 18420 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP(4.5)
Delegates (built-in): bzlib djvu fftw fontconfig freetype heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib

The Ubuntu repository provides ImageMagick 6.x, which uses separate commands like convert, identify, and mogrify. If you need ImageMagick 7 with the unified magick command and latest features, use the source compilation method below.

Method 2: Install ImageMagick from Source

Compiling from source installs ImageMagick 7, which uses the unified magick command instead of the legacy convert, identify, and other separate utilities. This method requires additional steps but provides access to the latest features and performance improvements.

Install Build Dependencies

Install the compiler toolchain and development libraries required for compilation:

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

This installs GCC and essential build tools along with image format libraries for JPEG, PNG, TIFF, and GIF support. The pkg-config package is required for the configure script to locate delegate libraries correctly. If you need to install or upgrade Git on Ubuntu, do so before proceeding.

Clone the Repository

Download the ImageMagick source code from the official GitHub repository. For production systems, clone a specific release tag rather than the development branch:

git clone --depth 1 --branch 7.1.1-43 https://github.com/ImageMagick/ImageMagick.git ~/ImageMagick
cd ~/ImageMagick

The --depth 1 flag creates a shallow clone without full history, reducing download size significantly. The --branch flag specifies a stable release tag. Check the releases page for the latest stable version and substitute accordingly. Version numbers in this guide are examples current at the time of writing.

Configure the Build

Run the configure script to detect your system configuration and prepare the build:

./configure --with-modules

The --with-modules flag enables dynamic loading of image format coders, which allows ImageMagick to support additional formats without recompilation. The script checks for available libraries and displays a summary of enabled features.

A successful configuration ends with output similar to:

ImageMagick is configured as follows:
...
Host system type: x86_64-pc-linux-gnu
Build system type: x86_64-pc-linux-gnu

Option                          Value
---------------------------------------------------------------
Shared libraries  --enable-shared=yes       yes
Static libraries  --enable-static=yes       yes
Module support    --with-modules=yes        yes

Compile and Install ImageMagick

Compile ImageMagick using all available CPU cores to speed up the build:

make -j$(nproc)

The compilation takes several minutes depending on your system. Afterward, you can optionally run the test suite to verify the build before installation:

make check

The make check test suite validates ImageMagick’s core functionality. Some tests require Ghostscript and FreeType to pass completely. Minor test failures typically do not affect normal usage; check the Advanced Linux Source Installation guide for troubleshooting specific failures.

When ready, install ImageMagick system-wide:

sudo make install

Verify the installation created the necessary files:

ls /usr/local/bin/magick

You should see:

/usr/local/bin/magick

Update Library Cache

Configure the dynamic linker to find the new ImageMagick libraries:

sudo ldconfig /usr/local/lib

The ldconfig command refreshes the shared library cache so your system can find the newly installed ImageMagick libraries. Without this step, you will encounter “cannot open shared object file” errors when running ImageMagick commands.

Verify Source Installation

Confirm the installation by checking the version and performing a quick test conversion:

/usr/local/bin/magick --version

You should see ImageMagick 7.x output:

Version: ImageMagick 7.1.1-43 Q16-HDRI x86_64 22341 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5)
Delegates (built-in): bzlib fontconfig freetype jng jpeg lcms ltdl lzma png tiff webp xml zlib

Test the installation with a quick image conversion using the built-in logo:

/usr/local/bin/magick logo: logo.gif && ls -la logo.gif

You should see a new logo.gif file created (approximately 27KB):

-rw-rw-r-- 1 user user 27055 Nov 29 12:00 logo.gif

Check which image formats are available in your installation:

magick identify -list format | head -30

The format list and delegate list vary depending on which optional libraries were detected during configuration. ImageMagick supports over 200 image formats. Common variations include additional support for HEIC, JXL, or PDF formats if their respective development libraries are installed.

Troubleshoot ImageMagick on Ubuntu

Library Loading Errors

If you see a shared library error when running ImageMagick commands after source installation, the dynamic linker cannot find the ImageMagick libraries. This typically happens because source installations place libraries in /usr/local/lib, which may not be in your system’s default library search path.

The error looks like:

magick: error while loading shared libraries: libMagickCore-7.Q16HDRI.so.10: cannot open shared object file: No such file or directory

To resolve this, first verify the library files exist:

ls /usr/local/lib/libMagick*

You should see the ImageMagick library files listed:

/usr/local/lib/libMagickCore-7.Q16HDRI.so.10
/usr/local/lib/libMagickCore-7.Q16HDRI.so.10.0.0
/usr/local/lib/libMagickWand-7.Q16HDRI.so.10
/usr/local/lib/libMagickWand-7.Q16HDRI.so.10.0.0
/usr/local/lib/libMagick++-7.Q16HDRI.so.5
/usr/local/lib/libMagick++-7.Q16HDRI.so.5.0.0

Run the ldconfig command to update the library cache:

sudo ldconfig /usr/local/lib

Verify the fix by checking the version again:

magick --version

Missing Delegate Libraries

If certain image formats fail to process, the required delegate library may not have been detected during configuration. To diagnose this, use grep to check delegates compiled into ImageMagick:

magick identify -list configure | grep DELEGATES

Common missing delegates and their packages:

  • HEIC/HEIF: Install libheif-dev
  • WebP: Install libwebp-dev
  • PDF/PS: Install ghostscript and libgs-dev
  • RAW: Install libraw-dev

After installing additional libraries, you must reconfigure and rebuild ImageMagick to enable support.

Configure ImageMagick Resource Limits on Ubuntu

ImageMagick uses memory, disk, and CPU resources when processing images. To understand your system’s configuration, view your current resource limits:

magick identify -list resource

You should see output similar to:

Resource limits:
  Width: 100MP
  Height: 100MP
  Area: 25.181GB
  Memory: 11.726GiB
  Map: 23.452GiB
  Disk: unlimited
  File: 768
  Thread: 12
  Time: unlimited

For batch processing large images or running ImageMagick on a web server, configure limits to prevent resource exhaustion:

magick -limit memory 2GiB -limit map 4GiB input.jpg -resize 50% output.jpg

For production environments, configure permanent limits in the policy.xml file. Use the sed command to edit policy values directly from the terminal, or see the Security Policy Guide for detailed configuration options including format restrictions, path controls, and resource constraints.

Process Images with ImageMagick on Ubuntu

The commands below use ImageMagick 7 syntax with the unified magick command. If you installed via APT (ImageMagick 6.x), replace magick with convert in the examples below. Both versions support the same image operations with identical syntax for the operations themselves.

Convert Image Formats

Convert a JPG image to PNG format when you need lossless compression or transparency support:

magick input.jpg output.png

ImageMagick automatically detects the output format from the file extension. This works with over 200 image formats including WebP, HEIC, PDF, and SVG.

Create Thumbnails

Generate a 200×200 pixel thumbnail while preserving aspect ratio for image previews or galleries:

magick input.png -thumbnail 200x200 thumbnail.png

The -thumbnail option strips metadata and optimizes the image for web use, resulting in smaller file sizes than -resize.

Resize Images

Resize an image to exactly 800×600 pixels when you need precise dimensions regardless of aspect ratio:

magick input.png -resize 800x600! output.png

The exclamation mark forces the exact dimensions, ignoring aspect ratio. Without it, ImageMagick maintains the original proportions within the specified bounds.

Add Text Watermarks

Overlay text on an image to protect copyright or add attribution:

magick input.png -font Arial -pointsize 36 -fill black -gravity southeast -annotate +10+10 "Copyright 2026" output.png

This places the text in the bottom-right corner with a 10-pixel margin. The -gravity option controls positioning relative to the image edges.

Batch Process Multiple Files

Convert all JPG files in a directory to PNG when migrating image formats for an entire project:

magick mogrify -format png *.jpg

The mogrify subcommand modifies files in place. The original JPG files remain unchanged while new PNG versions are created alongside them. For more complex batch operations, combine ImageMagick with find -exec to process files matching specific criteria across nested directories. For more examples and advanced techniques, see Examples of ImageMagick Usage.

Remove ImageMagick from Ubuntu

Remove APT Installation

If you installed ImageMagick via APT, remove the package and clean up unused dependencies:

sudo apt remove imagemagick
sudo apt autoremove

Verify ImageMagick is removed:

convert --version

You should see:

Command 'convert' not found, but can be installed with:
sudo apt install imagemagick-6.q16

Remove Source Installation

If you compiled from source, run the uninstall target from the source directory:

cd ~/ImageMagick && sudo make uninstall

Update the library cache:

sudo ldconfig

Verify ImageMagick is removed:

magick --version

You should see:

bash: magick: command not found

Delete the cloned source directory to free disk space:

rm -rf ~/ImageMagick

Remove Configuration Files

Both installation methods create system-wide configuration files in /etc/ImageMagick-6/ or /etc/ImageMagick-7/ depending on the version. To remove these:

The following command permanently removes ImageMagick system configuration including security policies. Only proceed if you are completely removing ImageMagick from your system.

sudo rm -rf /etc/ImageMagick-*

User-specific settings may also exist in your home directory:

The following command removes any custom ImageMagick policies or settings you may have configured. Skip this step if you want to preserve your customizations for a future reinstall.

rm -rf ~/.config/ImageMagick

Verify the directory no longer exists:

ls ~/.config/ImageMagick

You should see:

ls: cannot access '/home/user/.config/ImageMagick': No such file or directory

Frequently Asked Questions

What is the difference between ImageMagick 6 and ImageMagick 7?

ImageMagick 6 uses separate commands (convert, identify, mogrify) while ImageMagick 7 unifies them under a single magick command. Version 7 also includes HDRI by default for better color precision and improved performance. Ubuntu’s APT repositories provide version 6; version 7 requires source compilation.

Why does ImageMagick show a “command not found” error after source installation?

Source installations place the magick binary in /usr/local/bin/, which may not be in your shell’s PATH. Run sudo ldconfig /usr/local/lib to update the library cache, then open a new terminal session. If the issue persists, use the full path /usr/local/bin/magick or add /usr/local/bin to your PATH.

Can I have both ImageMagick 6 and ImageMagick 7 installed on Ubuntu?

Yes. The APT package installs version 6 to /usr/bin/ while source compilation installs version 7 to /usr/local/bin/. Both can coexist because they use different binary names (convert vs magick) and install to separate directories.

Additional Resources

For more information about ImageMagick:

Conclusion

You now have ImageMagick installed on Ubuntu and ready for image processing tasks. The APT method provides stable format conversion using the convert command, while the source compilation delivers ImageMagick 7 with the unified magick command. Extend your workflow by integrating ImageMagick with PHP on Ubuntu for dynamic image generation, or explore GIMP on Ubuntu and Inkscape on Ubuntu for graphical editing workflows.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffee Buy me a coffee

Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<a href="URL">link</a> link
<blockquote>quote</blockquote> quote block

Leave a Comment

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: