-resize, -crop, -extent, -thumbnail, -scale, -sample, and other options that manipulate image dimensions. The authoritative overview is Command-line processing (geometry) on imagemagick.org; this page summarizes the parts doc readers use most often.
Base syntax
Unless noted, examples assume a 1600×1200 source (4∶3 aspect ratio). For “fit inside” sizes, ImageMagick uses scale = min(W/w, H/h) so neither output dimension exceeds the box.Geometry dimensions are in pixels. ImageMagick does not factor in DPI or print resolution when interpreting geometry strings. An image at 300 DPI and an image at 72 DPI with the same pixel dimensions receive the same resize result.
Resize modifier flags
Modifier flags are appended to the end of a geometry string. They change how ImageMagick handles aspect ratio and sizing constraints.Independent percentages on both axes (W%xH%)
Strings like 50%x25% scale width and height by different percentages, so the aspect ratio changes (unlike a single 50%, which scales both axes together). See the W%xH% row in the base syntax table. That trips people who expect 50%x25% to mean “50% overall.”
All examples below use a 1600x1200 input image and a target of 800x400.
No flag (default)
! Force exact dimensions
> Only shrink
< Only enlarge
^ Fill area
^ means “cover” the box, not “fit inside.” ImageMagick scales until both dimensions are at least the target (max(W/w, H/h)). For 1600×1200 into an 800×400 box, the width hits 800 first, producing 800×600. The image is 150px taller than the 400px target. That overflow is expected; you still need a crop or extent step if the deliverable must be exactly 800×400.
This is typically paired with -gravity center -extent (or -crop) to trim the extra:
Offset syntax
Offsets specify a position within the image, written as+X+Y or -X-Y after the dimensions. They are primarily used with -crop and -extent.
+repage resets the virtual canvas to match the cropped dimensions.
Negative offsets shift in the opposite direction:
Gravity and crop offsets
When-gravity is set, crop offsets are measured from the gravity anchor point instead of the top-left corner.
Offsets add to the anchor in the direction ImageMagick defines for that gravity (see the official geometry page for edge cases).
-gravity persists for all subsequent spatial operations until explicitly reset. To reset it:
-gravity None resets it.
Options that accept geometry
Resize operations (all preserve aspect ratio by default, all accept modifier flags):
Crop and extent operations (use
WxH+X+Y offset syntax):
Edge cases
x600 vs 0x600
These are different. x600 omits the width, so ImageMagick calculates it proportionally from the height. 0x600 specifies a width of zero, which produces a 1x1 pixel output. Always omit the dimension rather than setting it to zero.
Two-axis percentages (50%x25%)
Covered in the base table above: width and height scale independently, so the picture stretches unless both percentages match.
Decimal percentages
Values like33.3% are valid. ImageMagick rounds the result to the nearest whole pixel. A 1600x1200 image at 33.3% becomes 533x400.
Area resize (@)
The @ flag targets an approximate pixel count rather than specific dimensions. 640000@ on a 1600x1200 image produces 924x693 (area = 640,332). The result preserves aspect ratio and gets as close to the target area as possible.
Shell escaping
The>, <, ^, and ! characters have special meaning in most shells. Wrap geometry strings in single quotes on Linux/macOS ('800x600>') or double quotes on Windows ("800x600>"). The backslash escape (800x600\>) also works on Linux/macOS.
See also
- Common options reference for
-strip,-quality,-gravity,-background,-composite, and related flags used together with geometry in real commands.