ImageMagick handles resizing, cropping, format conversion, thumbnails, and batch image jobs directly from the Ubuntu terminal. This guide covers ImageMagick installation on Ubuntu 26.04, 24.04, and 22.04 LTS using the default APT package or a source build when you need a newer upstream release, then walks through verification, troubleshooting, and practical command examples.
Install ImageMagick on Ubuntu
Ubuntu includes ImageMagick in the official repositories, and source compilation remains a good option when you need a newer upstream release. The table below compares the two installation paths before you choose a method.
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| APT Package | Official repos | Distribution default | Automatic via apt upgrade | Most users who want stable packages with automatic updates |
| Compile from Source | GitHub Releases | Latest stable | Manual recompilation | Developers who need the latest features or custom builds |
Recommendation: Start with the APT package unless you specifically need a newer ImageMagick release than your Ubuntu repository provides. The source method takes longer to maintain, but it gives you current upstream releases and the full ImageMagick 7 command set on older Ubuntu LTS versions.
Default ImageMagick Versions by Ubuntu Release
| Ubuntu Release | Default ImageMagick | Primary CLI Command | Notes |
|---|---|---|---|
| Ubuntu 26.04 LTS | ImageMagick 7.1.2-x | magick (and convert) | APT package provides ImageMagick 7.x by default |
| Ubuntu 24.04 LTS | ImageMagick 6.9.12-x | convert | Legacy ImageMagick 6 command set in the default repositories |
| Ubuntu 22.04 LTS | ImageMagick 6.9.11-x | convert | Legacy ImageMagick 6 command set in the default repositories |
These steps cover Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS. The APT installation command is the same across all three releases, but Ubuntu 26.04 installs ImageMagick 7.x with the
magickcommand while Ubuntu 24.04 and 22.04 install ImageMagick 6.x with the legacy tools such asconvert.
Method 1: Install ImageMagick via APT
The APT method installs the Ubuntu-packaged ImageMagick release with security updates through apt. Ubuntu 26.04 provides ImageMagick 7.x, while Ubuntu 24.04 and 22.04 provide ImageMagick 6.x, so the post-install command names differ by release.
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 which command Ubuntu linked by default, then check the installed version:
command -v magick || command -v convert
convert --version
You should see output similar to:
/usr/bin/convert Version: ImageMagick 6.9.12-98 Q16 x86_64 18420 https://legacy.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
Ubuntu 22.04 and 24.04 usually return
/usr/bin/convertand an ImageMagick 6.x version line. Ubuntu 26.04 returns/usr/bin/magickand ImageMagick 7.x (withconvertstill available throughupdate-alternatives). If you need themagickcommand on Ubuntu 22.04 or 24.04, 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 curl git pkg-config libltdl-dev libjpeg-dev libpng-dev libtiff-dev libgif-dev libfreetype6-dev liblcms2-dev libxml2-dev
This installs GCC and build tools on Ubuntu plus the delegate libraries needed for common formats such as JPEG, PNG, TIFF, and GIF. The
curlpackage is used to query the latest stable ImageMagick release tag from GitHub, andpkg-confighelps the configure script locate installed libraries correctly. If you need to install or upgrade Git on Ubuntu, do that before continuing.
Download the Latest Stable Source Release
Pull the latest stable release tag from the official ImageMagick GitHub repository, then clone only that tagged release. This avoids building the development branch, which can report beta versions between stable releases:
IMAGEMAGICK_TAG=$(curl -fsSL https://api.github.com/repos/ImageMagick/ImageMagick/releases/latest | grep -oE '"tag_name": "[^"]+"' | head -n 1 | cut -d '"' -f4)
git clone --depth 1 --branch "$IMAGEMAGICK_TAG" https://github.com/ImageMagick/ImageMagick.git ~/ImageMagick
cd ~/ImageMagick
The
IMAGEMAGICK_TAGvariable stores the latest stable GitHub release tag (for example,7.1.2-13). The--depth 1flag performs a shallow clone to reduce download size, and--branch "$IMAGEMAGICK_TAG"ensures you build a stable release instead of a beta snapshot frommain.
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 checktest 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.x.x-x Q16-HDRI x86_64 ... 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 fontconfig freetype jng jpeg lcms ltdl lzma png tiff webp xml zlib
The exact version line matches the current stable release tag returned by the GitHub API command used earlier. If you see a beta label in the version output, you likely built the
mainbranch instead of a release tag.
Test the installation with a quick image conversion using the built-in logo:
/usr/local/bin/magick logo: logo.gif && ls -lh logo.gif
You should see a new logo.gif file created (roughly 28KB on current builds):
-rw-rw-r-- 1 user user 28K Feb 22 12:04 logo.gif
Check which image formats are available in your installation:
/usr/local/bin/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.
Create an ImageMagick Source Update Script (Optional)
If you plan to keep a source-built ImageMagick installation, use a small update script so you can rebuild from the latest stable GitHub release tag without editing commands each time. Run this only after the source-build prerequisites in this section are installed.
Create the script file in your home directory:
nano ~/update-imagemagick.sh
Paste the script below, save with Ctrl+O, press Enter, then exit nano with Ctrl+X:
#!/usr/bin/env bash
set -euo pipefail
# Latest stable release metadata from GitHub.
REPO_API="https://api.github.com/repos/ImageMagick/ImageMagick/releases/latest"
BUILD_DIR="$HOME/ImageMagick"
INSTALL_BIN="/usr/local/bin/magick"
for cmd in curl git grep head cut make sudo; do
if ! command -v "$cmd" >/dev/null; then
echo "Missing required command: $cmd"
exit 1
fi
done
echo "Checking latest stable ImageMagick release..."
LATEST_TAG=$(curl -fsSL "$REPO_API" | grep -oE '"tag_name": "[^"]+"' | head -n 1 | cut -d '"' -f4)
LATEST_VERSION="${LATEST_TAG#v}"
if [ -x "$INSTALL_BIN" ]; then
CURRENT_VERSION=$("$INSTALL_BIN" --version | grep -oE 'ImageMagick [0-9]+\.[0-9]+\.[0-9]+-[0-9]+' | head -n 1 | cut -d ' ' -f2)
else
CURRENT_VERSION="not installed"
fi
echo "Current installed version: $CURRENT_VERSION"
echo "Latest stable version: $LATEST_VERSION"
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
echo "ImageMagick is already up to date."
exit 0
fi
echo "Removing old source tree..."
rm -rf "$BUILD_DIR"
echo "Cloning ImageMagick $LATEST_VERSION..."
git clone --depth 1 --branch "$LATEST_TAG" https://github.com/ImageMagick/ImageMagick.git "$BUILD_DIR"
cd "$BUILD_DIR"
echo "Configuring build..."
./configure --with-modules
echo "Compiling (this may take a few minutes)..."
make -j"$(nproc)"
echo "Installing to /usr/local (sudo required)..."
sudo make install
sudo ldconfig /usr/local/lib
echo "Update complete."
/usr/local/bin/magick --version | head -n 1
Make the script executable, then run it:
chmod +x ~/update-imagemagick.sh
~/update-imagemagick.sh
Expected output looks similar to:
Checking latest stable ImageMagick release... Current installed version: 7.1.2-13 Latest stable version: 7.1.2-13 ImageMagick is already up to date.
Run the update script manually when you need a newer ImageMagick release. Avoid scheduling source rebuilds in cron on production systems because library changes can interrupt image-processing jobs or dependent applications without warning.
Troubleshoot ImageMagick on Ubuntu
Fix “magick: command not found” on Ubuntu
If Ubuntu reports magick: command not found after installation, the most common cause is an ImageMagick 6 package install from Ubuntu 22.04 or 24.04. Those releases install the legacy commands (convert, identify, mogrify) instead of the unified magick command.
The error usually looks like:
bash: magick: command not found
Check which command Ubuntu installed and confirm the packaged version:
command -v magick || command -v convert
apt-cache policy imagemagick | grep Installed
On Ubuntu 22.04 or 24.04 APT installs, you will usually see:
/usr/bin/convert Installed: 8:6.9.12.98+dfsg1-5.2build2
Use one of these fixes depending on what you need:
- Stay on the Ubuntu package: Use
convert,identify, andmogrifyinstead ofmagick. - Need the unified
magickcommand on Ubuntu 22.04/24.04: Use the source compilation method in this guide to install ImageMagick 7 under/usr/local/bin/magick. - Ubuntu 26.04 users: The default APT package already includes
magick, so reinstallingimagemagickusually restores the command if it was removed.
Verify the command that works on your system:
convert --version | head -n 1
Version: ImageMagick 6.9.12-98 Q16 x86_64 ...
Fix Shared Library Loading Errors After Source Installation
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
Version: ImageMagick 7.x.x-x Q16-HDRI x86_64 ...
Fix Missing Delegate Libraries in ImageMagick
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
ghostscriptandlibgs-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. If you only need quick conversions and thumbnails, skip to the next section and come back here when tuning large batch jobs or server workloads. To inspect your current limits:
Ubuntu 22.04 and 24.04 APT installs use ImageMagick 6, so use the legacy equivalents
identify -list resourceandconvert -limit ...if themagickcommand is unavailable.
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.xmlfile. 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. Ubuntu 26.04 APT installs already provide magick, while Ubuntu 22.04 and 24.04 APT installs use ImageMagick 6.x and the legacy standalone tools. Use the equivalent command for your release instead of blindly replacing everything with convert.
| ImageMagick 7 Syntax (this guide) | ImageMagick 6 Equivalent on Ubuntu 22.04/24.04 APT |
|---|---|
magick input.jpg output.png | convert input.jpg output.png |
magick identify -list resource | identify -list resource |
magick mogrify -format png *.jpg | mogrify -format png *.jpg |
Convert Image Formats with ImageMagick
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.
For a common Ubuntu command-line task, convert a phone photo from HEIC to JPG:
magick input.heic -quality 92 output.jpg
If HEIC conversion fails, confirm HEIC support in your delegates list and install
libheif-devbefore rebuilding a source install. Ubuntu APT packages usually include HEIC support when the required delegate libraries are available.
Create Thumbnails with ImageMagick
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 with ImageMagick
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 with ImageMagick
Overlay text on an image to protect copyright or add attribution:
magick input.png -font DejaVu-Sans -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. DejaVu-Sans is a safer default on Ubuntu than Arial, which is often not installed.
Batch Process Multiple Images with ImageMagick
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:
bash: convert: command not found
If
convertormagickstill works after removing the APT package, you likely still have a source-built installation in/usr/local. Continue with the next section to remove the source build.
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 the source-built binary was removed from /usr/local/bin:
ls /usr/local/bin/magick
You should see:
ls: cannot access '/usr/local/bin/magick': No such file or directory
On Ubuntu 26.04,
magickmay still be available from the APT package after removing the source build. Usecommand -v magickto confirm whether the active binary now points to/usr/bin/magick.
Delete the cloned source directory to free disk space:
The next command permanently deletes the local ImageMagick source tree in
~/ImageMagick. Skip it if you want to keep the source directory for future rebuilds or troubleshooting.
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
ImageMagick 6 uses separate commands such as convert, identify, and mogrify, while ImageMagick 7 adds the unified magick command and newer features. On Ubuntu, 22.04 and 24.04 install ImageMagick 6 from APT by default, while Ubuntu 26.04 installs ImageMagick 7.
Ubuntu 22.04 and 24.04 install ImageMagick 6 from APT, which uses legacy commands such as convert instead of magick. Use convert, or install ImageMagick 7 from source if you need the unified magick command. If the error happens after a source install, verify /usr/local/bin/magick exists and run sudo ldconfig /usr/local/lib.
Yes. On Ubuntu 22.04 and 24.04, the APT package installs ImageMagick 6 in /usr/bin/ while source compilation typically installs ImageMagick 7 in /usr/local/bin/, so both can coexist. On Ubuntu 26.04, APT already installs ImageMagick 7, so source installs are usually only needed for newer upstream releases.
No. The command-line tool in this guide is the imagemagick package, installed with apt install imagemagick. The similarly named imagick package usually refers to the PHP Imagick extension (php-imagick), which integrates ImageMagick with PHP applications.
ImageMagick Documentation and Resources
For more information about ImageMagick:
- ImageMagick GitHub Repository: Access the source code, report issues, and track development.
- ImageMagick Official Website: Browse documentation, command references, and usage examples.
- Security Policy Guide: Configure ImageMagick security settings for production environments.
- Command-Line Processing: Learn the complete anatomy of ImageMagick commands including geometry, operators, and image stacks.
- Supported Formats: Browse the complete list of 200+ image formats with format-specific options and notes.
- Usage Examples: Comprehensive examples for resizing, compositing, animations, distortions, and special effects.
- Community Discussions: Get help and share solutions with other ImageMagick users.
Conclusion
ImageMagick on Ubuntu is straightforward once you pick the right install path: APT for stable maintenance, or source when you need a newer upstream release or the ImageMagick 7 magick command on Ubuntu 22.04/24.04. Before troubleshooting or removal, always confirm which binary is active in /usr/bin or /usr/local/bin. Extend the workflow with PHP on Ubuntu for server-side image generation, or pair it with GIMP on Ubuntu and Inkscape on Ubuntu for GUI editing tasks.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>