Worried a smaller PNG will turn blurry? Here is how to compress png without losing quality: run a lossless optimizer such as oxipng, which repacks the file’s data and leaves the picture untouched.
This guide is part of our series on how to edit png images, and it covers the file-size side of that work.
| Item | Value |
|---|---|
| Default oxipng optimization level | Level 2 |
| Size added by interlacing | 25-50% of an optimized image |
| ZopfliPNG gain over convert -q 95 (corpus of 1000 PNGs) | 12% compression improvement |
| ZopfliPNG gain over pngout | 0.5% compression improvement |
| ZopfliPNG CPU time compared with libpng | 2-3 orders of magnitude more |
The figures come from the oxipng man page and the ZopfliPNG README. They can change as the tools are updated, so check the source before you rely on them.
Why can a PNG shrink without losing detail?
PNG already stores pixels without loss, so the savings come from packing the same data more cleverly. Before compression, a step called filtering rewrites each row of pixels so the data becomes more compressible, although filtering by itself does not make the data smaller, as the PNG optimization guide explains.
The image type matters too. If an RGB image has 256 distinct colors or less, it can be re-encoded as a palette image, which cuts the amount of data the compressor has to handle, according to the same guide.
Because an encoder makes many choices, two programs can turn identical pixels into files of very different sizes. The guide says PNG compression may vary within wide limits, depending on the compressor’s implementation (source).
A good optimizer works on several fronts at once. According to the ZopfliPNG README, its feature list includes:
- Stronger Deflate compression through Zopfli.
- Comparing several strategies for choosing scanline filter codes.
- Choosing a suitable color type to encode the image losslessly.
None of these steps changes what the image looks like, which is why optimizing is the safest way to shrink a PNG.

Compress a PNG with oxipng, step by step
The oxipng man page describes the tool as a lossless PNG compression optimizer, and a basic run needs only a file path (source). Follow these steps:
- Work on a copy of your image, because oxipng overwrites the file by default.
- Run oxipng path/to/file.png to compress a single file.
- Add –out path/to/output.png if you would rather save the result as a new file.
- Run oxipng “*.png” to compress every PNG in the current directory using multiple threads.
- Add –dry-run first when you only want to see the compression results without writing any files.
You can also tune effort. The default level 2 is quite fast and provides good compression, while higher levels squeeze out more with increasingly diminishing returns, according to the man page.
Try –opt max when file size matters more than waiting time, such as for a final export. Lower levels are faster, which suits quick passes over big folders.
This site has no affiliation with oxipng, ZopfliPNG or any other tool maker, and no tool mentioned here is sponsored.
When Zopfli is worth the wait
Zopfli is a stronger Deflate compressor, and oxipng can use it through the –zopfli option. The man page calls it much slower but stronger and recommends using it with -o max (source).
ZopfliPNG is a separate command line program for the same job. In the README’s initial testing on a corpus of 1000 PNGs with translucency, it gave a compression improvement of 12% compared to convert -q 95, but only 0.5% compared to pngout (source).
That gain has a price in time. Compared with libpng, ZopfliPNG uses 2-3 orders of magnitude more CPU time for compression, per the same README.
The authors are candid about the limits: they hope to make images on the web load faster without a new image format, but the opportunities for optimization within PNG are limited. Treat Zopfli as a final polish for images you will serve many times, not as a daily habit.
Which settings can change how your image looks?
Default lossless runs keep every visible detail, but a few options trade fidelity for size. Know these before you switch them on:
- –alpha alters the color values of fully transparent pixels. The man page calls this “visually lossless” but technically a lossy transformation that may be unsuitable for some applications (source).
- –scale16 forcibly reduces images with 16 bits per channel to 8 bits per channel. The same man page labels this a lossy operation.
- –strip all removes every non-critical chunk and will convert APNGs to standard PNGs, so animations stop animating (source).
- –interlace on can add 25-50% to the size of an optimized image, according to the man page.
Interlacing is a poor trade for size in PNG. Unlike JPEG, where interlacing may improve compression slightly, PNG interlacing degrades compression significantly (source).
Metadata deserves a look as well. ZopfliPNG removes ancillary chunks that normally do not affect rendering, and the README suggests –keepchunks=gAMA,pHYs if you need to keep gamma and DPI information (source).
Check the result before you publish
The ZopfliPNG README advises you to visually check the output in the target renderer (source). Treat that as a rule for any optimizer. A short routine helps:
- Open the original and the optimized file side by side in the place they will be shown.
- Zoom in on soft edges, gradients and transparent areas.
- Compare file sizes, and keep the original in a safe folder.
Do edits that change pixels first, then optimize last so you do not repeat work. Our walkthrough on how to make a png background transparent covers cutting out a backdrop.
If the file is still too heavy after optimizing, the pixel dimensions are the other lever. Our guide on how to resize a png shows how to change them.
Frequently asked questions
Is compressing a PNG always lossless?
Show answer
No. A plain optimizer run rewrites the data without altering the picture, but options such as –alpha and bit-depth scaling are described in the oxipng man page as technically lossy. Leave them off when exact pixel values matter.
Should I choose oxipng or ZopfliPNG?
Show answer
Start with oxipng at its defaults for everyday files, since it is quick. Move to Zopfli only for final exports where an extra few percent is worth a long wait.
Will optimizing remove my image’s metadata?
Show answer
It depends on the tool and flags. Per the oxipng man page, the default when –strip is not passed is to keep all chunks that remain valid, while ZopfliPNG removes ancillary chunks unless you ask it to keep them.
Should I leave interlacing on?
Show answer
Only if progressive display matters more to you than size. oxipng’s TL;DR notes that its default is off, which also avoids the size penalty.



