If you work with images on Linux resizing, converting formats, or batch-processing graphics you’ve probably heard of ImageMagick.
It’s one of the most powerful and flexible image manipulation tools available for Ubuntu and other Linux distributions.
In this guide, I’ll explain what ImageMagick is, how to install it easily on Ubuntu, how to verify the installation, and a few basic usage examples to get you started.
What Is ImageMagick?
ImageMagick is an open-source command-line tool that lets you create, edit, convert, and manipulate images in almost any format you can think of JPEG, PNG, GIF, TIFF, PDF, and more.
You can use it for:
- Converting images between formats (like
.jpg
to.png
) - Resizing or compressing images
- Adding text, watermarks, or filters
- Creating thumbnails
- Processing multiple images in bulk using shell scripts
It’s lightweight, runs directly from the terminal, and is a must-have for developers, designers, and Linux users who handle images often.
How to Install ImageMagick on Ubuntu
Let’s go step by step.
Step 1: Update Your System
Before installing anything, it’s a good idea to update your package list.
Open your terminal and run:
sudo apt update
If you want to update all installed packages as well, use:
sudo apt upgrade
Step 2: Install ImageMagick
Ubuntu makes it super simple — ImageMagick is already available in the official Ubuntu repository.
Just run:
sudo apt install imagemagick -y
That’s it. The -y
flag automatically confirms the installation.
This command installs both the ImageMagick command-line utilities and the core libraries required to manipulate images.
Step 3: Verify Installation
Once installed, check the version to confirm that everything is working properly:
magick -version
or
convert -version
You should see output showing the ImageMagick version, supported file formats, and build details.
If you see a version number (like ImageMagick 7.1.1-29
), that means it’s successfully installed.
Optional: Install Development Libraries (For Advanced Users)
If you’re compiling software that depends on ImageMagick (for example, PHP’s imagick
extension or Python’s wand
library), you’ll also need the development libraries.
Run this command:
sudo apt install libmagickwand-dev
This installs the development headers and libraries required for programming integrations.
Basic ImageMagick Commands
Once installed, you can use ImageMagick to perform hundreds of image operations.
Here are a few quick examples:
1. Convert Image Format
Convert a PNG image to JPEG:
magick input.png output.jpg
or (older versions):
convert input.png output.jpg
2. Resize an Image
Resize an image to 800×600 pixels:
magick input.jpg -resize 800x600 output.jpg
3. Compress an Image
Reduce image quality to 70% (useful for web optimization):
magick input.jpg -quality 70 output.jpg
4. Add Text or Watermark
Add text to the bottom-right corner of an image:
magick input.jpg -gravity southeast -pointsize 20 -fill white -annotate +10+10 '© Pratham Writes' output.jpg
5. Create Thumbnails in Bulk
If you have a folder full of images and want thumbnails for all of them:
mogrify -path thumbnails/ -resize 200x200 *.jpg
The command creates a “thumbnails” folder and saves smaller versions of all .jpg
files inside it.
Troubleshooting Common Issues
Here are a few common problems and how to fix them:
1. “Command not found” error:
If you type convert
or magick
and get a “command not found” message, try reinstalling:
sudo apt install --reinstall imagemagick
2. Permission issues when writing files:
If ImageMagick can’t write to a folder, use sudo
or make sure you have write permissions.
3. Security restrictions:
Some Ubuntu versions have restrictive policies (via “policy.xml”).
If ImageMagick refuses certain image operations, edit /etc/ImageMagick-6/policy.xml
carefully — or switch to magick
commands instead of convert
for newer versions.
Difference Between ImageMagick 6 and 7
Ubuntu repositories sometimes include ImageMagick 6 by default.
If you want ImageMagick 7 (the latest major version), you can install it manually using Snap or from the official source.
Install using Snap:
sudo snap install imagemagick
Check version:
magick -version
Snap usually provides the latest release.
🔄 Uninstall ImageMagick (If Needed)
If you ever want to remove ImageMagick completely:
sudo apt remove imagemagick -y
sudo apt autoremove -y
This removes the tool and its unused dependencies.
Wrap Up
ImageMagick is one of those tools that’s simple yet extremely powerful once you start using it.
You can resize, compress, convert, and even automate image workflows all from your terminal.
If you work with websites, graphics, or automation scripts, installing ImageMagick on Ubuntu will save you tons of manual effort.
Try experimenting with commands, and you’ll realize how much it can do beyond basic conversions.
Quick Summary
Task | Command |
---|---|
Update system | sudo apt update && sudo apt upgrade |
Install ImageMagick | sudo apt install imagemagick -y |
Verify installation | magick -version |
Resize image | magick input.jpg -resize 800x600 output.jpg |
Convert format | magick input.png output.jpg |
Compress image | magick input.jpg -quality 70 output.jpg |
Uninstall | sudo apt remove imagemagick -y |