Skip to content
MagickCmd › Geometry

ImageMagick geometry cheat sheet

The single most confusing thing in ImageMagick: the suffix on a geometry argument changes the behaviour completely.

SyntaxMeansWhat actually happens
800x600Fit inside the boxScales down until both dimensions fit. Aspect ratio kept, so the result is usually smaller than 800×600 on one axis.
800x600!Force exactly this sizeIgnores the aspect ratio and stretches. Almost never what you want.
800x600^Fill the box, overflow allowedScales until both dimensions are at least 800×600. Pair with -gravity center -extent 800x600 to crop the overflow.
800x600>Only shrink if largerImages already smaller pass through untouched. The safe default for user uploads.
800x600<Only enlarge if smallerImages already larger pass through untouched.
50%Percentage of the originalScales both axes. 50%x25% scales them independently.
1000000@Target total pixel countCaps area rather than width or height — useful across images of mixed shapes.
800Width onlyHeight is computed from the aspect ratio.
x600Height onlyThe leading x is what makes it a height. Forgetting it is the single most common ImageMagick mistake.
800x600+30+20Size plus offsetUsed by -crop, -extent, -geometry. The offset is from the top-left, or from -gravity when one is set.
+24+24Offset onlyWith -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.

Copied