Compress an image from the command line on Mac (sips + ImageMagick + pngquant)
Three command-line tools, three flavours of image compression on macOS. Here's what each one is good at.
You’re in Terminal and you’d like to shrink an image without leaving it. macOS gives you one tool out of the box and Homebrew gives you the rest. Here’s the practical guide to all three, with the actual flags that work.
sips (built into macOS)
sips is the Scriptable Image Processing System — Apple’s built-in CLI for the same image pipeline Preview uses. Zero install.
JPEG re-encode at quality 80:
sips -s format jpeg -s formatOptions 80 input.jpg —out output.jpg
PNG re-encode at maximum zlib compression:
sips -s format png —setProperty formatOptions 100 input.png —out output.png
Resize the longest edge to 2000px (preserves aspect ratio):
sips -Z 2000 input.jpg —out resized.jpg
Combine everything:
sips -s format jpeg -s formatOptions 80 -Z 2000 input.jpg —out small.jpg
What sips is good at: zero-install, fast, predictable, handles HEIC. What it’s not good at: no PNG quantization (modest PNG savings), no MozJPEG-grade encoding.
ImageMagick (mogrify / magick)
Install:
brew install imagemagick
Single file, JPEG at quality 80, resized:
magick input.jpg -quality 80 -resize 2000x2000> output.jpg
(The \> means “only resize if larger than 2000.”)
Batch a folder in place (overwrites originals — be careful):
mogrify -path compressed/ -quality 80 -resize 2000x2000> *.jpg
Convert PNG to JPEG:
magick input.png -quality 80 output.jpg
Convert to WebP:
magick input.jpg -quality 80 -resize 2000x output.webp
What ImageMagick is good at: format conversion, complex resize/crop, WebP/AVIF output, batch via mogrify. What it’s not good at: absolute smallest PNGs (doesn’t quantize by default).
pngquant (the missing piece)
Install:
brew install pngquant
Basic use:
pngquant —quality=70-90 —strip input.png
Writes input-fs8.png next to the original. To overwrite in place:
pngquant —quality=70-90 —strip —ext .png —force input.png
Batch a folder:
for f in *.png; do pngquant —quality=70-90 —strip —ext .png —force “$f”; done
What pngquant is good at: the actual smallest PNGs. 60-85% reductions where sips gets 15%. What it’s not good at: PNG only. For JPEG you want cjpeg from mozjpeg or jpegoptim:
brew install jpegoptim && jpegoptim —max=80 —strip-all input.jpg
When the CLI stops being worth it
Three tools, three sets of flags to memorise, no progress bar, no preview. If you’re shrinking one image, the CLI is fine. If you’re doing this all the time, the friction adds up — that’s where Melt starts to pay for itself.
- Download Melt if you'd rather drag than type.
- Drag images in.
- Pick format, quality, optional resize.
- Click Compress.
Under the hood it’s the same pipeline — pngquant for PNG, MozJPEG-grade encoding for JPEG, libheif for HEIC. Same results, different friction.
How much smaller will it really get?
For a fair comparison, all three CLI tools at “quality 80” produce roughly equivalent JPEG output (within 5-10%). For PNG, pngquant beats sips and ImageMagick by a wide margin because it’s the only one that quantizes. Honestly — the right answer is to learn sips for quick one-offs, pngquant for PNG-heavy work, and ImageMagick for anything involving format conversion.
More Melt tips
-
Receive iPhone photos as JPG via AirDrop (not HEIC)
AirDropping photos from iPhone keeps landing them as HEIC files on your Mac. Here's how to get them as JPG instead.
-
AVIF on Mac — opening and converting AVIF images
AVIF is the next-gen image format that's even smaller than WebP. Here's how to open and convert AVIF files on macOS.
-
How to batch compress a folder of photos on Mac
Compressing 200 photos one at a time is its own form of suffering. Here's how to batch compress images on macOS.
-
What's the best image format for the web (and how to export it on Mac)?
JPEG, PNG, WebP, AVIF, SVG — they each have a job. Here's how to pick the right one for the web and export it from your Mac.