Resize images from the terminal with ImageMagick
The classic forgotten-syntax task: shrinking a photo or converting formats without a GUI — including the gotcha that `1280x` means keep the aspect ratio.
Run `magick input.jpg -resize 1280x output.jpg` to scale to a width of 1280 preserving aspect ratio; on older distros the same command is `convert input.jpg -resize 1280x output.jpg`.
01Command
Command
$ magick input.jpg -resize 1280x input_resized.jpg02What it does
The geometry suffix is the part everyone forgets: `1280x` fits within a 1280-wide box, `x800` fits a 800-tall box, and `1280x800!` forces exact dimensions, distorting if needed. Add `-quality 85` for smaller JPEG output and `-auto-orient` to fix EXIF rotation on phone photos. For a whole directory, remember `mogrify -resize 1280x *.jpg`, which overwrites the files in place — copy them first.
03Risk
!Warning: `mogrify` overwrites the original files in place; there is no undo, so work on copies.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- convert(1) — convert between image formats (ImageMagick)Evidence: Documents -resize geometry semantics (width-only preserves aspect ratio), -quality, and format conversion usage
Last verified: 2026-09-17 · Category: Media