ImageMagick resize command generator
Build the exact ImageMagick resize command. Explains ^ ! > < and % suffixes, keeps aspect ratio, makes exact-size thumbnails without distortion. IM7 and IM6 syntax.
Resizing is the first thing almost everyone uses ImageMagick for, and it is also where the most time gets lost — because -resize behaves completely differently depending on a single character you put after the size.
Set your options in the builder above and copy the command. The rest of this page explains what it is doing, so the next time you can write it yourself.
The five resize behaviours
| Command | What you get |
|---|---|
-resize 800x600 | Fits inside 800×600. Aspect ratio kept, so one side ends up smaller than asked. |
-resize 800x600! | Forces exactly 800×600 and squashes the image if the ratio differs. |
-resize '800x600^' | Fills the box, overflowing on one axis. Pair with -extent to crop the overflow. |
-resize '800x600>' | Shrinks only if the image is larger. Smaller images pass through untouched. |
-resize '800x600<' | Enlarges only if the image is smaller. |
Resize without distorting the image
Give -resize a plain WxH box and ImageMagick will never distort — it fits the image inside and preserves the aspect ratio. Distortion only happens when you add !.
magick input.jpg -resize 1200x1200 output.jpg
Resize to a width and let the height follow
magick input.jpg -resize 800 output.jpg # width 800
magick input.jpg -resize x600 output.jpg # height 600
That leading x is the single most common ImageMagick mistake. -resize 600 is a width; only -resize x600 is a height.
Exact-size thumbnails with no distortion
This is the recipe you actually want for avatars, product grids and card images — scale to cover the box, then trim the overflow from the centre:
magick input.jpg -resize '400x400^' -gravity center -extent 400x400 output.jpg
A bare -crop fails here, because images smaller than 400×400 would not fill the frame. The ^ guarantees full coverage first.
Only shrink large images, never upscale small ones
The standard safe transform for anything users upload:
magick input.jpg -resize '1600x1600>' -quality 85 output.jpg
The > must be quoted. Unquoted, your shell reads it as output redirection, silently drops it, and creates an empty file named 1600.
Which resize operator should you use?
-resize— filtered, high quality resampling. The default answer.-thumbnail— a fast pre-scale then resize, plus an automatic-strip. Fastest for galleries, but it drops ICC colour profiles as well as EXIF.-scale— simple pixel averaging with no filter. Use for pixel art and for pixelation effects.-sample— pure nearest neighbour. Picks pixels, never blends.
Sharpening after a downscale
Every downscale softens edges. A conservative unsharp mask restores them without producing halos:
magick input.jpg -resize 1200 -unsharp 0x0.75+0.75+0.008 output.jpg
Resize every image in a folder
mkdir -p out
for f in *.jpg; do
magick "$f" -resize '1600x1600>' -quality 85 "out/${f%.*}.jpg"
done
mogrify -resize '1600x1600>' *.jpg does the same in one line but overwrites your originals in place. If you use it, always add -path out. Tick “Batch mode” in the builder above to get the loop for your shell.