Skip to content

Compress Images Without Losing Quality on Windows (Free)

Compress images without losing quality on Windows free using WSL. Lossless JPG and PNG optimization with jpegoptim, optipng, and ImageMagick — all offline, no uploads.

MGMCSA Guru Team June 11, 2026 4 min read
A WSL terminal compressing JPG and PNG files losslessly with jpegoptim and optipng on Windows

“Compress without losing quality” gets thrown around loosely, so it’s worth being honest up front: PNG really can be made smaller with zero pixel change, while JPG is already compressed, so the free wins there come from stripping junk and re-optimizing what’s there. Push a JPG further and you’re trading a little quality, whether a tool admits it or not.

The good news is you control exactly where that line sits, and you do it for free without uploading a single file. WSL gives you the three tools that handle this best — optipng for lossless PNG, jpegoptim for JPG, and ImageMagick when you want one tool for everything.

Don’t have WSL yet? Our WSL install guide gets you there in one command.

Install the optimizers

sudo apt update && sudo apt install -y jpegoptim optipng imagemagick

That’s three tools: jpegoptim (JPG), optipng (PNG), and imagemagick (magick/convert, format-agnostic).

Lossless PNG compression with optipng

PNG is where “no quality loss” is literally true. optipng repacks the image data more efficiently; the pixels are untouched.

optipng image.png

Push it harder with a higher optimization level (slower, sometimes smaller):

optipng -o5 image.png

Whole folder:

for f in *.png; do optipng -o5 "$f"; done

The savings depend entirely on how the PNG was originally saved — files exported by some apps shrink a lot, already-optimized ones barely move.

JPG: strip metadata first (genuinely lossless)

The cleanest JPG win is removing metadata without re-encoding the image. That’s lossless — the pixels don’t change:

jpegoptim --strip-all image.jpg

--strip-all drops EXIF, comments, and thumbnails. The image looks identical; the file is smaller. As a bonus, it also clears embedded data like camera info and GPS location. (For thorough metadata removal across formats, see remove image metadata.)

JPG: go a bit smaller (visually lossless)

When stripping isn’t enough, cap the quality. jpegoptim -m85 only re-compresses files above quality 85 down to it — usually invisible, noticeably smaller:

jpegoptim -m85 --strip-all image.jpg

Whole folder:

for f in *.jpg; do jpegoptim -m85 --strip-all "$f"; done

Lower the number for smaller files, but check the results — somewhere around 80–85 is the usual sweet spot for photos.

One tool for everything: ImageMagick

If you’d rather not install several utilities, ImageMagick handles both formats and writes to a new file (so it doesn’t overwrite the source):

magick input.jpg -strip -quality 85 output.jpg
  • -strip removes metadata.
  • -quality 85 sets JPG quality.

For PNG, ImageMagick can also reduce size, though optipng usually beats it for pure lossless packing:

magick input.png -strip output.png

Which tool, which job

optipng -o5 f.png Lossless PNG repack — identical pixels
jpegoptim --strip-all f.jpg Lossless JPG — strips metadata only
jpegoptim -m85 --strip-all f.jpg Visually lossless JPG — small quality cap
magick in -strip -quality 85 out One tool, writes a new file
for f in *.jpg; do ... done Batch a whole folder

A sensible workflow

For a folder of mixed images you want to slim down for the web without visible loss:

cp -r originals/ work/ && cd work/
for f in *.png; do optipng -o5 "$f"; done
for f in *.jpg *.jpeg; do [ -e "$f" ] && jpegoptim -m85 --strip-all "$f"; done

Copy first, optimize PNGs losslessly, optimize JPGs to a visually-lossless cap. Compare a few against the originals before you trust the batch.

Wrapping up

“Without losing quality” is real for PNG and mostly about stripping and smart re-optimization for JPG. optipng repacks PNGs losslessly, jpegoptim --strip-all trims JPG metadata with zero pixel change, and -m85 gives a visually-lossless extra squeeze when you need it. ImageMagick covers both if you want a single tool.

All of it is free, batchable, and runs in WSL — so your images never get uploaded to a compressor site. Work on copies, compare the output, and you’ll trim folders of images safely.

Frequently asked questions

Can you really compress an image without losing any quality?

For PNG, yes — tools like optipng repack the file losslessly, so the pixels are identical and the file is smaller. For JPG, truly lossless gains come mostly from stripping metadata and re-optimizing the existing data; squeezing more usually means a small, controlled quality drop you set yourself.

What's the difference between lossless and visually lossless?

Lossless means the decoded image is pixel-for-pixel identical to the original. Visually lossless means a tiny amount of data is discarded but you can't see the difference at normal viewing. PNG optimization is lossless; a JPG saved at quality 85 is usually visually lossless.

Does stripping metadata reduce image quality?

No. Metadata is EXIF, color profiles, thumbnails, and comments — not image pixels. Removing it with -strip shrinks the file without touching how the image looks, and it also clears data like GPS location, which is a privacy win.

Will these tools upload my photos anywhere?

No. jpegoptim, optipng, and ImageMagick all run locally in WSL, so the images stay on your disk. That's the main reason to use them instead of an online compressor for anything private.

Should I keep a backup before compressing in place?

Yes. jpegoptim and optipng overwrite the original file by default. Copy your images to a working folder first, or use a tool's dry-run/output option, so you always have the untouched source if something looks off.

Sources & further reading

Official vendor documentation referenced while writing this guide.

MG

MCSA Guru Team

IT & Systems Administration

We are working IT pros and system administrators who spend our days in Windows Server, Microsoft 365, and the wider Microsoft stack. MCSA Guru is where we write down the fixes and walkthroughs we wish we had found the first time.

MCSA Guru provides independent, educational IT guidance. Microsoft, Windows, Windows Server, Microsoft 365, Exchange, and Microsoft Teams are trademarks of Microsoft Corporation; Docker is a trademark of Docker, Inc. MCSA Guru is not affiliated with or endorsed by Microsoft or Docker. Always test changes in a safe environment before applying them in production.

Related guides

Fixing something right now?

Jump straight into the guide library or search for the exact error or task you are dealing with.