How to Install ImageMagick on Ubuntu 26.04, 24.04 and 22.04

Last updated Wednesday, May 6, 2026 11:00 am Joshua James 8 min read

Batch image work gets old quickly when every resize, conversion, thumbnail, or watermark needs a graphical editor. To install ImageMagick on Ubuntu, start with the imagemagick package from Ubuntu’s universe component unless you specifically need a current upstream source build. Ubuntu 26.04 installs ImageMagick 7 with the magick wrapper, while Ubuntu 24.04 and 22.04 install ImageMagick 6, where convert remains the portable command.

The APT package is the best default for most systems because Ubuntu handles updates and package integration. Source compilation is useful for custom delegates, module builds, or the newest upstream ImageMagick release, but it also makes updates and removal your responsibility. PHP users should note that php-imagick is a separate extension; the Install PHP Imagick on Ubuntu guide covers that stack-specific package.

Install ImageMagick on Ubuntu

Install the Ubuntu package first unless you already know you need ImageMagick 7 on an older LTS release or a custom source build. The package name is imagemagick, not magick or imagick.

Update Ubuntu Package Index

Refresh APT metadata before installing packages from Ubuntu’s repositories:

sudo apt update

These commands use sudo for package-management tasks. If your account does not have sudo access yet, add it with the guide to add a new user to sudoers on Ubuntu, or run the commands from a root shell.

Install ImageMagick Package

Install ImageMagick from Ubuntu’s universe component:

sudo apt install imagemagick

Standard Ubuntu desktop installs usually have universe enabled already. Minimal, server, cloud, or customized systems can return E: Unable to locate package imagemagick until universe is enabled; the troubleshooting section includes the fix and links the full Universe and Multiverse guide for Ubuntu.

Verify ImageMagick Version

Check the portable command first, then check whether the ImageMagick 7 wrapper exists on your release:

command -v convert
convert --version | head -n 1
command -v magick || true

Relevant output on Ubuntu 26.04 includes both convert and magick:

/usr/bin/convert
Version: ImageMagick 7.1.2-18 Q16 x86_64 23822 https://imagemagick.org
/usr/bin/magick

Ubuntu 24.04 and 22.04 currently show an ImageMagick 6 version line and no /usr/bin/magick from the APT package. Use convert, identify, and mogrify on those releases unless you install ImageMagick 7 from source.

Compare ImageMagick Branches by Ubuntu Release

Ubuntu ReleaseAPT BranchDefault CommandsRepository Component
Ubuntu 26.04 LTSImageMagick 7.1.2.xmagick and convertuniverse
Ubuntu 24.04 LTSImageMagick 6.9.12.xconvert, identify, mogrifyuniverse
Ubuntu 22.04 LTSImageMagick 6.9.11.xconvert, identify, mogrifyuniverse

Install ImageMagick Development Headers on Ubuntu

Skip this section for normal command-line image conversion. Install the development package only when compiling software against ImageMagick libraries or when another build asks for MagickWand headers.

sudo apt install libmagickwand-dev pkg-config

Confirm the MagickWand development metadata with:

pkg-config --modversion MagickWand

On Ubuntu 26.04, libmagickwand-dev follows the ImageMagick 7 package branch. On Ubuntu 24.04 and 22.04, it follows ImageMagick 6 and may pull in packages such as imagemagick-6-common. That is expected for the Ubuntu development headers. It is separate from php-imagick, which is the PHP extension rather than the CLI toolkit or C development package.

Compare ImageMagick Installation Methods on Ubuntu

The default package is enough for most systems. Use source only when the packaged branch or delegate set does not meet your requirement.

MethodVersion and CommandsUpdate PathBest For
APT packageUbuntu repository package from universe. Ubuntu 26.04 ships ImageMagick 7, while Ubuntu 24.04 and 22.04 ship ImageMagick 6.Updated with normal APT package upgrades.Most users, servers, scripts, and production systems.
Source buildCurrent upstream release from the ImageMagick GitHub releases, installed under /usr/local.Manual rebuild and reinstall from the source tree.Advanced users who need current upstream behavior, custom delegates, or module builds.

For Ubuntu systems, APT handles the packaged build, and the source workflow handles upstream ImageMagick 7 needs without adding a third-party APT source or manually tracking source archives. The source workflow links the release page for release notes but uses Git tags, so updates can reuse the same source tree.

Install ImageMagick from Source on Ubuntu

Source builds follow ImageMagick’s official source installation workflow: clone a release tag, configure, build, install, and refresh the dynamic linker. This workflow keeps the source tree in $HOME/src/imagemagick-build and installs binaries under /usr/local.

APT and source builds can coexist, but /usr/local/bin often appears before /usr/bin in PATH. If you only want one ImageMagick command set, remove the APT package before installing from source.

Install Source Build Dependencies

Install the compiler, Git, module support, and common image delegate development packages:

sudo apt install git build-essential pkg-config libtool libltdl-dev libjpeg-dev libpng-dev libtiff-dev libgif-dev libfreetype-dev liblcms2-dev libxml2-dev libwebp-dev libheif-dev libraw-dev ghostscript libgs-dev

The dependency list includes libltdl-dev because this build enables module support with --with-modules. The delegate packages cover common JPEG, PNG, TIFF, GIF, WebP, HEIC, RAW, FreeType, XML, and Ghostscript workflows. If you want more background on Git before cloning the source tree, the Install or Upgrade Git on Ubuntu guide covers the package separately.

Clone the Latest ImageMagick Release

Create a source directory, detect the latest ImageMagick release tag, and clone that tag from the upstream repository:

mkdir -p "$HOME/src"
cd "$HOME/src"
LATEST_TAG="$(git ls-remote --refs --tags https://github.com/ImageMagick/ImageMagick.git | awk -F/ '/refs\/tags\/[0-9]+\.[0-9]+\.[0-9]+-[0-9]+$/ {print $3}' | sort -V | tail -n 1)"

if [ -z "$LATEST_TAG" ]; then
  echo "Could not detect the latest ImageMagick release tag."
  exit 1
fi

if [ -e imagemagick-build ]; then
  echo "$HOME/src/imagemagick-build already exists. Move or remove it before cloning again."
  exit 1
fi

printf 'Latest ImageMagick tag: %s\n' "$LATEST_TAG"
mkdir imagemagick-build
git -C imagemagick-build init --quiet
git -C imagemagick-build remote add origin https://github.com/ImageMagick/ImageMagick.git
git -C imagemagick-build fetch --quiet --depth 1 origin "refs/tags/$LATEST_TAG:refs/tags/$LATEST_TAG"
git -C imagemagick-build -c advice.detachedHead=false checkout --quiet "$LATEST_TAG"
cd imagemagick-build

The printed release tag changes over time. A current example tag is 7.1.2-21.

Configure ImageMagick Source Build

Configure ImageMagick with module support and without PerlMagick. The --without-perl flag keeps this source workflow focused on the command-line tools and avoids installing Perl module files outside the main ImageMagick prefix.

./configure --with-modules --without-perl

Relevant configuration lines should include module support and the delegates detected from the development packages:

Module support      --with-modules=yes          yes
PERL                --with-perl=no              no
FEATURES            = Channel-masks(32-bit) Cipher DPC HDRI Modules OpenMP
DELEGATES           = bzlib freetype heic jbig jng jpeg lcms ltdl lzma png raw tiff webp xml zlib zstd

Compile and Install Source-Built ImageMagick

Compile with one job per CPU core, install the build, and refresh the dynamic linker cache so Ubuntu can locate the new libraries under /usr/local/lib:

make -j"$(nproc)"
sudo make install
sudo ldconfig /usr/local/lib

Verify Source-Built ImageMagick

Check the source-built binary directly from /usr/local/bin:

/usr/local/bin/magick --version

For tag 7.1.2-21, relevant output includes:

Version: ImageMagick 7.1.2-21 Q16-HDRI x86_64 51e1d5d97:20260421 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/license/
Features: Cipher DPC HDRI Modules OpenMP(4.5)
Delegates (built-in): bzlib freetype heic jbig jng jpeg lcms ltdl lzma png raw tiff webp xml zlib zstd

Your version line will change as ImageMagick publishes newer tags. The important checks are that the binary runs from /usr/local/bin, the feature list includes Modules, and the delegate list includes the formats you need. Ubuntu 22.04 can show a shorter delegate list than newer releases because its older library packages differ.

Run ImageMagick Command Examples on Ubuntu

These examples use ImageMagick’s built-in logo: image, so you can test commands without downloading sample files. They use convert for compatibility with Ubuntu 26.04, 24.04, and 22.04 APT installs. If you are writing specifically for ImageMagick 7, use the equivalent magick form.

Convert an Image Format with ImageMagick

Create a PNG file from ImageMagick’s built-in logo image:

convert logo: logo.png

Create an ImageMagick Thumbnail

Generate a 200×200 thumbnail while stripping unnecessary metadata:

convert logo.png -thumbnail 200x200 logo-thumb.png

Resize an Image with ImageMagick

Resize an image to fit within 800×600 pixels while preserving the original aspect ratio:

convert logo.png -resize 800x600 logo-resized.png

Add Text to an Image with ImageMagick

Create a simple banner with centered text. Ubuntu normally includes the DejaVu font family, so DejaVu-Sans is a safer example than assuming Arial exists:

convert -size 800x200 xc:navy -font DejaVu-Sans -pointsize 36 -fill white -gravity center -annotate +0+0 "Ubuntu ImageMagick" banner.png

Batch Process Images with ImageMagick

Convert all JPG files in the current directory to PNG files. mogrify writes new PNG files beside the originals because the output format differs:

mogrify -format png *.jpg

For nested directories, combine ImageMagick with find -exec so the shell does not expand only the current directory.

Configure ImageMagick Resource Limits on Ubuntu

ImageMagick can consume significant memory, temporary disk space, and CPU time when processing large images. Check the active runtime limits before tuning batch jobs or web-server workloads:

convert -list resource

For one command, add temporary limits directly to the conversion:

convert -limit memory 2GiB -limit map 4GiB logo: -resize 50% output.png

Permanent limits live in ImageMagick’s policy.xml file. Locate the package-managed policy file with:

for package in imagemagick-6-common imagemagick-7-common; do
  dpkg -L "$package" 2>/dev/null || true
done | grep '/policy.xml$'

Ubuntu 26.04 uses /etc/ImageMagick-7/policy.xml. Ubuntu 24.04 and 22.04 use /etc/ImageMagick-6/policy.xml. Make a backup before editing this file because overly broad policy changes can weaken ImageMagick’s default safety restrictions. For the policy syntax, see ImageMagick’s security policy documentation.

Troubleshoot ImageMagick on Ubuntu

Most Ubuntu ImageMagick issues come from command-name differences, disabled repository components, source-built library paths, or missing delegate libraries.

magick Command Not Found on Ubuntu

Ubuntu 24.04 and 22.04 install ImageMagick 6 from APT, so this error is expected when you try to run magick after the standard package install:

bash: magick: command not found

Use convert on those releases, or use the source-build method if you specifically need ImageMagick 7:

convert --version

APT Cannot Locate ImageMagick

If APT cannot find imagemagick, enable Ubuntu’s universe component and refresh package metadata. The software-properties-common package provides add-apt-repository on minimal systems:

sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update
sudo apt install imagemagick

For more detail on Ubuntu repository components, use the guide to enable Universe and Multiverse on Ubuntu. ImageMagick only needs universe; do not enable multiverse just for this package.

Shared Library Error After Source Install

Source installs place libraries under /usr/local/lib. If the dynamic linker cache was not refreshed, magick can fail with a shared-library error similar to this:

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

Refresh the linker cache, then check the source-built binary again:

sudo ldconfig /usr/local/lib
/usr/local/bin/magick --version

Missing Format Support in ImageMagick

When a format fails with a “no decode delegate” or “no encode delegate” message, check which delegates the active ImageMagick command can see:

convert -list configure | grep 'DELEGATES'

The line should start with DELEGATES and then list the formats enabled for the active command. Exact entries differ by Ubuntu release and by the libraries present when ImageMagick was built, so look for the specific format that failed, such as JPEG, PNG, TIFF, WebP, HEIC, or FreeType support. Source builds that include libraw-dev should also list raw.

If a source build missed a delegate, install the matching development package and rebuild. For example, WebP, HEIC, RAW, and Ghostscript-related workflows use these packages:

sudo apt install libwebp-dev libheif-dev libraw-dev ghostscript libgs-dev
cd "$HOME/src/imagemagick-build"
./configure --with-modules --without-perl
make -j"$(nproc)"
sudo make install
sudo ldconfig /usr/local/lib

Update Source-Compiled ImageMagick on Ubuntu

If you built from source, create a repeatable update command in /usr/local/bin. The sudo tee command writes the script to a root-owned path; plain shell redirection would not have permission to create that file.

cat <<'EOF' | sudo tee /usr/local/bin/update-imagemagick-source > /dev/null
#!/usr/bin/env bash
set -euo pipefail

BUILD_DIR="${BUILD_DIR:-$HOME/src/imagemagick-build}"

if [ ! -d "$BUILD_DIR/.git" ]; then
  echo "Build directory not found: $BUILD_DIR"
  echo "Run the source installation steps first, or set BUILD_DIR=/path/to/imagemagick-build."
  exit 1
fi

cd "$BUILD_DIR"

if ! git diff --quiet || ! git diff --cached --quiet; then
  echo "Build directory has uncommitted changes. Review or stash them before updating."
  exit 1
fi

CURRENT_TAG="$(git describe --tags --exact-match 2>/dev/null || git describe --tags --abbrev=0 2>/dev/null || echo unknown)"
LATEST_TAG="$(git ls-remote --refs --tags https://github.com/ImageMagick/ImageMagick.git | awk -F/ '/refs\/tags\/[0-9]+\.[0-9]+\.[0-9]+-[0-9]+$/ {print $3}' | sort -V | tail -n 1)"

echo "Current tag: $CURRENT_TAG"
echo "Latest tag:  $LATEST_TAG"

if [ -z "$LATEST_TAG" ]; then
  echo "No ImageMagick release tags found."
  exit 1
fi

if [ "$CURRENT_TAG" = "$LATEST_TAG" ]; then
  echo "ImageMagick source tree is already on the latest tag."
  exit 0
fi

if [ -f Makefile ]; then
  sudo make uninstall || true
  make distclean || true
fi

git fetch --depth 1 origin "refs/tags/$LATEST_TAG:refs/tags/$LATEST_TAG"
git -c advice.detachedHead=false checkout --quiet "$LATEST_TAG"
./configure --with-modules --without-perl
make -j"$(nproc)"
sudo make install
sudo ldconfig /usr/local/lib
/usr/local/bin/magick --version
EOF

Make the updater executable, then confirm the shell can find the short command. The chmod command in Linux guide covers permission basics separately.

sudo chmod 0755 /usr/local/bin/update-imagemagick-source
command -v update-imagemagick-source
/usr/local/bin/update-imagemagick-source

Run the updater manually when you want to check for a newer ImageMagick tag:

update-imagemagick-source

Run source updates manually instead of scheduling them with cron. Source builds can fail because of changed dependencies, compiler errors, or network problems, and you want to see that output before replacing a working install.

Remove ImageMagick from Ubuntu

Use the removal path that matches the installation method you used.

Remove APT-Installed ImageMagick

Remove the metapackage and the versioned ImageMagick command package. The quoted package pattern lets APT match imagemagick-7.q16 on Ubuntu 26.04 or imagemagick-6.q16 on Ubuntu 24.04 and 22.04:

sudo apt remove imagemagick 'imagemagick-*.q16'

If APT suggests an autoremove cleanup afterward, preview the package list first:

sudo apt autoremove --dry-run

Continue only if the preview contains packages you are comfortable removing:

sudo apt autoremove

Clear the shell command cache and verify that no ImageMagick command package remains installed:

hash -r
dpkg -l imagemagick 'imagemagick-*.q16' | grep '^ii' || echo "ImageMagick packages are not installed"
ImageMagick packages are not installed

Use sudo apt purge instead of sudo apt remove only when you also want to delete package-owned configuration files under /etc/ImageMagick-6/ or /etc/ImageMagick-7/.

Remove Source-Compiled ImageMagick

Use ImageMagick’s upstream make uninstall target from the same source tree and configuration that installed it:

cd "$HOME/src/imagemagick-build"
sudo make uninstall
sudo rm -f /usr/local/bin/update-imagemagick-source
sudo ldconfig

The next command permanently deletes the source tree under $HOME/src/imagemagick-build. Keep it if you made local changes or want to inspect the build logs later.

rm -rf "$HOME/src/imagemagick-build"

Confirm the source-built binary is gone. If the Ubuntu APT package is still installed, /usr/bin/convert may still exist, but /usr/local/bin/magick should not:

test -x /usr/local/bin/magick && echo "source build still present" || echo "source build removed"
source build removed

Conclusion

ImageMagick is ready on Ubuntu for shell-based conversion, resizing, thumbnail generation, watermarking, and scripted image cleanup. Keep the APT package for stable maintenance and use the source build only when you need current upstream ImageMagick 7 behavior or custom delegate support. For web applications, pair the CLI tools with PHP Imagick on Ubuntu; for GUI editing, use GIMP on Ubuntu or Inkscape on Ubuntu.

Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

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 in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

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

Let us know you are human: