Compress JPEG files

Shrink JPEGs while keeping photos looking good. JPEG is a safe delivery default, but modern formats can be even smaller.

Last updated: 2026-03-18

To compress JPEG files, run npx optimo photo.jpg. Optimo applies ImageMagick-powered compression by default. For stronger reduction, use --lossy or --resize to shrink dimensions — often the single biggest lever for file size.

Start with optimo

First, run optimo on your image file:

npx optimo photo.jpg

This is safe: optimo keeps the original if the output isn't smaller.

Two big levers

1) Lossy mode
npx optimo photo.jpg --lossy
2) Resize (dimensions)
npx optimo photo.jpg --resize w1280

Practical tips

  • Use `--lossy` when you can tolerate small quality loss for big size wins.
  • If you control delivery, try converting to WebP/AVIF for smaller files.
  • Resizing down (even slightly) can reduce size more than recompressing.

Consider converting

Sometimes the best compression is picking a better delivery format.

Popular conversions

Frequently asked questions

How do I compress JPEG files?
Run "npx optimo photo.jpg" to compress JPEG with lossless optimization. For stronger compression, add --lossy. For size reduction through resizing, add --resize followed by a percentage, dimensions, or target file size.
What is the best way to reduce JPEG file size?
The two biggest levers are resizing (reducing dimensions to match display size) and lossy compression. Resizing usually has a larger impact than codec-level compression. Sometimes converting to a more efficient format is the best approach.