ImageMagick Quick Guide
Use ImageMagick to inspect, resize, convert and batch-process images with repeatable commands and safer output habits.
Updated September 5, 2026
On this page
Why use ImageMagick
ImageMagick is useful when an image task must be repeated across a folder, a build pipeline or a server. A saved command documents exactly how an output was produced and can be reviewed alongside code.
Modern ImageMagick examples normally use the magick command. Check the installed version because older systems may expose commands differently.
Inspect before changing files
Use identify through the main command to inspect dimensions and format:
magick identify input.jpg
For selected fields:
magick identify -format "%f %m %w x %h\n" input.jpg
Inspection helps catch unexpected orientation, animation, color profiles or very large dimensions before a batch job begins.
Resize without enlarging
Fit an image within a 1600 by 1600 box while preserving aspect ratio:
magick input.jpg -auto-orient -resize "1600x1600>" output.jpg
The > prevents smaller images from being enlarged. Quote geometry strings so the shell does not interpret their special characters.
To fill exact dimensions, resize and crop deliberately:
magick input.jpg -auto-orient -resize "1200x630^" -gravity center -extent 1200x630 social.jpg
The caret asks ImageMagick to cover the box; extent then crops around the selected gravity point.
Convert format and control quality
magick input.png -strip -quality 82 output.webp
-strip removes profiles and metadata. Use it only when that is intentional, and verify color afterward. Quality values depend on the output encoder, so compare visual results rather than copying one number to every format.
For a transparent source going to JPEG, choose the background explicitly:
magick input.png -background white -alpha remove -alpha off output.jpg
Otherwise transparent pixels may become an unexpected color.
Process a batch safely
Write outputs to a separate directory so source files are never overwritten accidentally:
mkdir -p output
magick mogrify -path output -auto-orient -resize "1600x1600>" -format webp -quality 82 *.jpg
Test on a copied sample folder first. Shell wildcard behavior differs across operating systems, and file names can contain spaces or unusual characters.
For complex automation, iterate over an explicit file list rather than constructing commands from untrusted input.
Remove metadata selectively
-strip removes metadata broadly. If a color profile is required, preserve or reapply it and compare in a color-managed viewer. Orientation should normally be applied with -auto-orient before removing the orientation tag.
Keep the original when capture information, copyright metadata or editing history matters.
Avoid common surprises
- The order of operations matters; ImageMagick evaluates options in sequence.
- Animated inputs may contain multiple frames when you expected one image.
- PDF and SVG processing can involve external delegates and separate security policies.
- Very large images require significant memory and temporary disk space.
- A successful command does not prove the visual result is correct.
A production checklist
- Pin and record the ImageMagick version.
- Inspect representative input types.
- Write to a new output directory.
- Set dimensions, format, color and metadata behavior explicitly.
- Fail the job when commands return an error.
- Compare outputs visually and measure bytes.
- Restrict untrusted formats and resource usage on servers.
Refer to the official ImageMagick command-line processing guide for option order, image lists and command structure.