ImageMagick geometry cheat sheet
The single most confusing thing in ImageMagick: the suffix on a geometry argument changes the behaviour completely.
| Syntax | Means | What actually happens |
|---|---|---|
800x600 | Fit inside the box | Scales down until both dimensions fit. Aspect ratio kept, so the result is usually smaller than 800×600 on one axis. |
800x600! | Force exactly this size | Ignores the aspect ratio and stretches. Almost never what you want. |
800x600^ | Fill the box, overflow allowed | Scales until both dimensions are at least 800×600. Pair with -gravity center -extent 800x600 to crop the overflow. |
800x600> | Only shrink if larger | Images already smaller pass through untouched. The safe default for user uploads. |
800x600< | Only enlarge if smaller | Images already larger pass through untouched. |
50% | Percentage of the original | Scales both axes. 50%x25% scales them independently. |
1000000@ | Target total pixel count | Caps area rather than width or height — useful across images of mixed shapes. |
800 | Width only | Height is computed from the aspect ratio. |
x600 | Height only | The leading x is what makes it a height. Forgetting it is the single most common ImageMagick mistake. |
800x600+30+20 | Size plus offset | Used by -crop, -extent, -geometry. The offset is from the top-left, or from -gravity when one is set. |
+24+24 | Offset only | With -gravity southeast this means 24px in from the bottom-right corner. |
Why this is worth learning properly
Most ImageMagick confusion traces back to one of two things — option order, and geometry suffixes. The table above covers the second. Five characters, each changing -resize into a different operation, and none of them mentioned in the flag's name.
Geometry is not specific to -resize. The same syntax is read by -crop, -extent, -geometry, -border, -splice and -thumbnail, though not every operator honours every suffix.
Quote them
^ > < ! are all shell metacharacters. Unquoted in bash, -resize 800x600> is parsed as a redirect: you get an unconditionally resized image plus a stray empty file called 600, with no error. See the shell quoting page for the per-shell rules.