# Resize an image on Mac from the command line > Resize images from the Mac Terminal with sips: keep aspect ratio, cap the longest side, or force exact dimensions — one-liners for single files and whole folders, no app or upload. - Canonical page: https://obelisk.club/blog/resize-image-mac-terminal - Author: Peter Zhang - Published: 2026-06-25 - Tags: sips, images, terminal, mac To resize an image from the Mac Terminal, use the built-in `sips` command: `sips -Z 1200 photo.jpg --out photo-small.jpg` scales the longest side to 1200 pixels, keeps the aspect ratio and writes a copy. `sips` (*scriptable image processing system*) ships with every Mac, runs offline, and loops cleanly over a whole folder. The one thing to remember: `sips` edits **in place by default**. Point it at a file with no `--out`, and it overwrites the original. That's the single mistake that bites people. Every command below shows how to write to a copy instead. ## Check before you resize Before changing anything, read the current dimensions so you know what you're working with: ```bash sips --getProperty pixelWidth --getProperty pixelHeight photo.jpg ``` `-g` is the short form of `--getProperty`. You can pull `pixelWidth`, `pixelHeight`, `dpiWidth`, `dpiHeight`, `format`, and more. This is also how you verify a resize actually landed. ## Resize while keeping aspect ratio (the common case) Most of the time you want to constrain one dimension and let the other follow. That's `--resampleWidth` or `--resampleHeight`: ```bash # Scale to 800px wide, height kept in proportion, written to a copy sips --resampleWidth 800 photo.jpg --out photo-800.jpg # Scale to 600px tall, width auto-calculated sips --resampleHeight 600 photo.jpg --out photo-tall.jpg ``` `--out` is what saves the result somewhere new instead of clobbering the source. If `--out` names a folder, `sips` keeps the original filename inside it. ## Cap the longest side When you just want nothing bigger than N pixels — perfect for "make these email-friendly" — use `-Z` (`--resampleHeightWidthMax`). It scales so the **larger** dimension hits your limit, preserving aspect ratio whether the image is portrait or landscape: ```bash sips -Z 1200 photo.jpg --out photo-capped.jpg ``` One flag, works on any orientation. This is the most forgiving option for mixed batches. ## Force exact dimensions If you need precise width *and* height — say, a fixed thumbnail grid — use `-z` (`--resampleHeightWidth`). Note the order: **height first, then width**. ```bash # Force exactly 200 tall × 200 wide sips -z 200 200 photo.jpg --out thumb.jpg ``` This **ignores aspect ratio** and will stretch the image to fit. Reach for it only when you genuinely want a fixed box; otherwise stick with the aspect-preserving flags above. ## From most forgiving to most strict | Flag | What it does | Aspect ratio | Use when | |---|---|---|---| | `-Z` / `--resampleHeightWidthMax` | Caps the larger side | Preserved | Mixed batch, "nothing over Npx" | | `--resampleWidth` | Sets width, height follows | Preserved | Fixed-width layouts | | `--resampleHeight` | Sets height, width follows | Preserved | Fixed-height rows | | `-z` / `--resampleHeightWidth` | Forces exact H×W | **Ignored** | Rigid thumbnail boxes | ## Batch a whole folder This is where doing it in the **resize image mac terminal** workflow pays off over clicking through an app. A `for` loop scales every JPG into an output folder, leaving originals untouched: ```bash mkdir -p resized for f in *.jpg; do sips --resampleWidth 1024 "$f" --out "resized/$f" done ``` Quote `"$f"` so filenames with spaces survive. Because `--out` points at `resized/`, your source files are never modified. ## Resize and convert in one pass `sips` can change format at the same time with `-s format` (`--setProperty format`). Shrink and convert to JPEG in a single command: ```bash sips --resampleWidth 800 -s format jpeg photo.png --out photo.jpg ``` If converting formats is the real goal, that mechanic is the same one behind [converting HEIC to JPG on Mac](https://obelisk.club/blog/heic-to-jpeg-mac-batch). And once you're comfortable scripting `sips` over folders, the same loop instinct carries straight into [batch renaming files on Mac](https://obelisk.club/blog/batch-rename-files-mac). ## Three things worth remembering - **Always pass `--out` unless you mean to overwrite.** Without it, the original is gone. - **`-z` takes height then width** — and it stretches. If your output looks squashed, that's why; switch to `-Z` or `--resampleWidth`. - **Verify with `--getProperty`** after a batch run so you know the dimensions actually changed before you ship the files. To resize in the browser instead, the [image resizer tool](https://obelisk.club/tools/image-resizer) works on your files without uploading them. For more `sips` commands, see the [complete sips guide](https://obelisk.club/blog/macos-sips-command-line-guide). ## Sources - [sips — ss64.com/mac](https://ss64.com/mac/sips.html)