How to Install ImageMagick on Ubuntu 24.04 & 22.04

Deepak Prasad
Tested on Ubuntu 24.04 LTS and 22.04 LTS
Package imagemagick 8:6.9.12.98+dfsg1-5.2build2 (24.04)
ghostscript 10.02.1~dfsg1-0ubuntu7.9 (24.04 PDF delegate)
Applies to Ubuntu 24.04 LTS and 22.04 LTS
Privilege sudo or root for apt and edits under /etc/ImageMagick-6/
Scope Install ImageMagick 6 from Ubuntu repositories, verify with convert and identify, run a quick resize test, add Ghostscript for PDF delegates, read /etc/ImageMagick-6/policy.xml, and uninstall. Does not cover ImageMagick 7 (magick) on Ubuntu 26.04 or PHP php-imagick.
Related guides How to Install ImageMagick 7 on Ubuntu 26.04
bulk resize and convert images in Linux
Check Ubuntu version
apt command in Linux
NOTE
Ubuntu 26.04: That release ships ImageMagick 7 and the magick driver. Follow How to Install ImageMagick 7 on Ubuntu 26.04 instead of the convert-style examples on this page.
Short on time?Beta Get the gist of this 8-minute read in seconds, then ask follow-up questions

On Ubuntu 24.04 and 22.04, sudo apt install imagemagick installs ImageMagick 6. Your everyday commands are convert, identify, and mogrify. If a blog post only shows magick, it was written for 26.04.

Run convert --version, then a quick JPG-to-PNG test. Add Ghostscript when you need PDFs; if conversion still fails on files you trust, read /etc/ImageMagick-6/policy.xml before you change policy.


Quick answer

Item Ubuntu 24.04 / 22.04
ImageMagick branch 6 (6.9.12.x on 24.04, 6.9.11.x on 22.04)
Install sudo apt install imagemagick
Primary commands convert, identify, mogrify
Policy file /etc/ImageMagick-6/policy.xml

Confirm your release with check Ubuntu version before you copy examples from tutorials written for Ubuntu 26.04 and magick.


Choose an install method

Method Best for Jump to
APT Default — Ubuntu-managed ImageMagick 6 with security updates Install with APT
Source Newer upstream ImageMagick 7 tag or custom delegates Install from source
AppImage Portable ImageMagick 7 without make install AppImage

APT covers a normal ImageMagick 6 setup. Source or AppImage is only when you need magick on an LTS that still ships version 6 in the archive.


Install ImageMagick on Ubuntu 24.04 & 22.04 with APT

Refresh package indexes

Run sudo apt update first—the same apt flow as any other package install:

bash
sudo apt update

Install the ImageMagick package

Install the metapackage:

bash
sudo apt install -y imagemagick

APT pulls imagemagick-6.q16 and imagemagick-6-common automatically.

Verify the installed version

Check the version ImageMagick 6 reports through convert:

bash
convert --version
output
Version: ImageMagick 6.9.12-98 Q16 x86_64 18038 https://legacy.imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php

On 22.04, the version string shows 6.9.11-60 (or a newer security revision), but the same convert / identify workflow applies.

The Q16 line means this build uses 16-bit quantum depth per color channel.

Check which ImageMagick packages are installed

List installed DEB packages when you need the exact installed package version:

bash
dpkg -l 'imagemagick*'
output
ii  imagemagick           8:6.9.12.98+dfsg1-5.2build2 amd64  image manipulation programs -- binaries
ii  imagemagick-6-common  8:6.9.12.98+dfsg1-5.2build2 all    image manipulation programs -- infrastructure
ii  imagemagick-6.q16     8:6.9.12.98+dfsg1-5.2build2 amd64  image manipulation programs -- quantum depth Q16

See what Ubuntu would install before you run apt

When ImageMagick is not installed yet, apt-cache policy shows the candidate version:

bash
apt-cache policy imagemagick
output
imagemagick:
  Installed: 8:6.9.12.98+dfsg1-5.2build2
  Candidate: 8:6.9.12.98+dfsg1-5.2build2
  Version table:
 *** 8:6.9.12.98+dfsg1-5.2build2 500
        500 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages

Candidate should be 6.9.x, not a 7.1.x ImageMagick 7 package.


Test ImageMagick with a simple image conversion

Create a scratch directory, then build a solid-color JPEG:

bash
mkdir -p /tmp/im-test

Fill a tiny red rectangle and save it as JPEG:

bash
convert -size 120x80 xc:red /tmp/im-test/input.jpg

convert prints nothing on success, so turn the JPEG into a PNG:

bash
convert /tmp/im-test/input.jpg /tmp/im-test/output.png

ls should list the new PNG:

bash
ls -l /tmp/im-test/output.png
output
-rw-r--r-- 1 user user 169 Oct 20 10:59 /tmp/im-test/output.png

Shrink the test image to half size:

bash
convert /tmp/im-test/input.jpg -resize 50% /tmp/im-test/resized.jpg

identify prints geometry and format without writing a new file:

bash
identify /tmp/im-test/output.png
output
/tmp/im-test/output.png PNG 120x80 120x80+0+0 8-bit sRGB 2c 169B 0.000u 0:00.000

For more batch resize and format recipes, see bulk resize and convert images in Linux.


Install Ghostscript for PDF and PostScript

PDFs usually need Ghostscript as a delegate. Install it alongside ImageMagick:

bash
sudo apt install -y ghostscript

Confirm Ghostscript is on disk before you retry PDF conversion:

bash
dpkg -l ghostscript
output
ii  ghostscript  10.02.1~dfsg1-0ubuntu7.9 amd64  interpreter for the PostScript language and for PDF

Even with Ghostscript installed, security policy can block PDF/PS coders. Adjust policy only for trusted workloads (next section).

Do you need ImageMagick development headers?

You do not need development packages for normal convert or identify commands.

If you are compiling an application against ImageMagick, install the ImageMagick 6 development package:

bash
sudo apt install libmagickwand-6.q16-dev

php-imagick is different—it is the PHP extension, not the imagemagick command-line metapackage.


ImageMagick security policy on Ubuntu 24.04 and 22.04

ImageMagick 6 reads policy.xml to cap delegates, coders, and memory use:

Path Role
/etc/ImageMagick-6/policy.xml Default Ubuntu policy for convert / identify

List coder-related rules before you change anything:

bash
grep -E 'pattern="(PDF|PS|EPS)"' /etc/ImageMagick-6/policy.xml

Defaults vary by release and security updates, so read the file on your host.

When PDF conversion fails with a policy error on trusted documents:

  • Change only the minimum rule required (for example a specific <policy domain="coder" … pattern="PDF" /> entry)
  • Keep backups before you edit policy.xml
  • Avoid blanket rights="none" removals on systems that accept arbitrary uploads

ImageMagick documents policy design on its security policy page.


Optional: Install ImageMagick 7 from source

Build from source when you want ImageMagick 7 (magick) on 24.04 or 22.04 but keep apt’s ImageMagick 6, or when Ubuntu’s package lacks a delegate you need.

Install Git, the toolchain, and common delegate headers:

bash
sudo apt install -y git build-essential pkg-config libjpeg-dev libpng-dev libtiff-dev libwebp-dev libfreetype6-dev libxml2-dev liblcms2-dev

Clone a tagged upstream release (pick the current tag from ImageMagick’s site):

bash
git clone --depth 1 --branch 7.1.2-34 https://github.com/ImageMagick/ImageMagick.git ~/ImageMagick-src

Move into the source tree:

bash
cd ~/ImageMagick-src

Run the configure script so the build detects libraries on your system:

bash
./configure

Compile with parallel jobs, then install under /usr/local (this does not remove apt’s convert):

bash
make -j"$(nproc)"

Install the binaries and libraries:

bash
sudo make install

Refresh the dynamic linker cache so the system sees /usr/local/lib:

bash
sudo ldconfig /usr/local/lib

Source installation places ImageMagick 7 under /usr/local; it is not managed by APT. If you keep apt’s ImageMagick 6 installed, check which magick when a script picks the wrong binary.

Verify the ImageMagick 7 binary:

bash
/usr/local/bin/magick --version

Use the full path or put /usr/local/bin ahead of /usr/bin when scripts should call magick instead of convert.


Optional: Run ImageMagick 7 with AppImage

Download the current x86_64 AppImage from ImageMagick’s download page, then make it executable:

bash
chmod +x ImageMagick-*-x86_64.AppImage

Optionally rename it for simpler commands:

bash
mv ImageMagick-*-x86_64.AppImage magick

Verify:

bash
./magick --version

Upstream’s AppImage may ship with an open security policy. Define a policy.xml appropriate for your environment before you process untrusted files in production.


Troubleshooting

Symptom Likely cause Fix
E: Unable to locate package imagemagick universe disabled or stale indexes sudo add-apt-repository universe, sudo apt update, then sudo apt install imagemagick
convert: command not found Package not installed sudo apt install imagemagick; verify with convert --version
magick: command not found on 24.04/22.04 Release ships ImageMagick 6 only Use convert / identify, build ImageMagick 7 from source, or use an AppImage
no decode delegate for this image format Missing library or Ghostscript for PDF Install ghostscript and format libraries; for source builds, re-run ./configure
PDF conversion blocked Policy or missing Ghostscript Install ghostscript; review /etc/ImageMagick-6/policy.xml for trusted use only

When apt reports Unable to locate package imagemagick, enable universe and run sudo apt update—on minimal images you may need software-properties-common first; see add-apt-repository command not found.


Uninstall ImageMagick

Remove the metapackage when you no longer need the tools:

bash
sudo apt remove imagemagick

Drop configuration files as well with purge (see remove software on Ubuntu for remove vs purge):

bash
sudo apt purge imagemagick

Clean up unused dependencies:

bash
sudo apt autoremove

If you installed ImageMagick 7 under /usr/local, remove it from the same source tree with sudo make uninstall before you delete libraries by hand.


Summary

On 24.04 and 22.04, sudo apt install imagemagick gives you ImageMagick 6. convert, identify, and mogrify are the commands you use every day; policy sits in /etc/ImageMagick-6/policy.xml. convert --version plus one convert input.jpg output.png test is usually all you need on a server or desktop.

Add Ghostscript for PDF or PostScript. Only edit policy.xml when you know why you are loosening a rule—not as a quick fix on a host that takes random uploads.

Upgrade to 26.04 later? Switch to the ImageMagick 7 guide and magick so your scripts match the newer package.


References


Frequently Asked Questions

Does Ubuntu 24.04 use ImageMagick 6 or 7?

Yes—Noble ships ImageMagick 6 in apt (for example 8:6.9.12.98+dfsg1-5.2build2). Use convert and identify unless you built or installed ImageMagick 7 yourself.

Is the install the same on Ubuntu 22.04?

Yes for day-to-day commands: both releases ship ImageMagick 6 with convert, identify, and mogrify. The exact 6.9.11 vs 6.9.12 package revision differs; verify with convert --version on your host.

Why do tutorials show magick instead of convert?

ImageMagick 7 unified operations under magick. Ubuntu 26.04 adopted that branch; 24.04 and 22.04 stayed on ImageMagick 6. Translate magick input.jpg output.png to convert input.jpg output.png on those LTS releases.

Should I install php-imagick for shell conversions?

No. php-imagick is a PHP extension for web apps. For command-line conversion, install the imagemagick package only.

Finished reading?Beta Get the key takeaways in seconds, then ask follow-up questions
Omer Cakmak

Linux Administrator

Highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware.

  • Debian
  • Ubuntu
  • Linux
  • Red Hat Enterprise Linux
  • Shell Script
  • System Administration