Back to Blog
·4 min read

Resize an image on Mac from the command line

Resize an image on Mac from the command line

I don't have permission to fetch the source page, but the sips flag reference on ss64 is the canonical man-page content, which I can write against accurately. Here's the article:

---

Your Mac resizes images from the Terminal — no app, no upload

The reflex when someone needs to shrink a screenshot or batch-scale a folder of photos is to open an editor or paste files into some web tool. Skip both. Every Mac ships with sipsscriptable image processing system — a command-line tool that resizes, converts, and queries images without launching anything. It runs offline, touches nothing but the files you name, and scripts cleanly over a whole folder.

The one thing to internalize: 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 auto-calculated, 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. And once you're comfortable scripting sips over folders, the same loop instinct carries straight into batch renaming files on 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.

For everyday shrinking, converting, and batch work, sips is all you need — it's already installed, it's fast, and nothing leaves your machine.

Sources

#resize#image#terminal

Written by

Peter Zhang

Building local-first Mac & iOS productivity apps at Obelisk Club.