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.

LinuxresizebatchimagemagickconvertLow risk
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.jpg

02What 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

RiskLow risk
RequirementsRequires ImageMagick (apt install imagemagick / dnf install ImageMagick); use `convert` instead of `magick` on ImageMagick 6 distros (e.g. Ubuntu 24.04)
!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

Last verified: 2026-09-17 · Category: Media