What Does a PNG Optimizer Do and How Do You Reduce PNG File Size Without Losing Quality?
Updated
A PNG optimizer rewrites a PNG file so it takes fewer bytes while keeping the same pixel data. It does this by re-encoding the compressed data stream, stripping metadata, and removing redundant chunks — not by changing the image itself. The result is a lossless reduction: the picture you see after optimization is identical to the original. If you need smaller files than lossless compression allows, you have to accept some quality trade-off, usually through palette quantization. RIOT, a free desktop optimizer first released in 2008, handles both paths and lets you compare the result before saving.
What a PNG optimizer actually changes
PNG is already a lossless format, so an optimizer can't simply "compress harder" in the way a JPEG optimizer can. Instead it works on the file's internal structure:
- Re-encoding the IDAT stream — the pixel data is stored with DEFLATE compression. Different encoders produce different byte sizes for the same pixels. An optimizer tries stronger settings to shrink that stream.
- Removing metadata — color profiles, text chunks, timestamps, and editor-specific chunks add bytes without affecting what you see.
- Dropping redundant chunks — unnecessary ancillary chunks that some tools write by default.
- Filter selection — PNG applies per-scanline filters before compression. Choosing better filters for the specific image can meaningfully reduce size.
None of these steps alter pixel values, so the output is bit-for-bit equivalent in appearance. That's what "lossless PNG optimization" means.
Lossless vs. lossy PNG reduction
These are two different operations and they suit different images.
| Lossless | Lossy (palette quantization) | |
|---|---|---|
| What changes | File structure only | Number of colors reduced |
| Visual result | Identical | Can show banding or dithering |
| Best for | Screenshots, UI, text, line art | Photos, gradients, images with many colors |
| Typical savings | Modest | Large |
| Risk | Essentially none | Visible artifacts if pushed too far |
For graphics, icons, and screenshots — images with flat colors and sharp edges — lossless optimization is usually the right choice, and it can still cut a surprising number of bytes because these files often carry metadata and inefficient compression.
For photographic PNGs, lossless gains are limited. Reducing the color depth (for example, from 24-bit to an 8-bit palette) is where the real savings come from, but that's a lossy step and needs visual checking.
Matching the approach to the image type
The right settings depend on what's in the file:
- Icons and simple UI graphics — lossless, maximum compression. Few colors means the palette is already small; the win comes from encoding and metadata removal.
- Screenshots with text — lossless. Text edges are where quantization artifacts show up first, so avoid palette reduction unless you inspect closely.
- Logos with transparency — lossless. Transparency edges are sensitive to color reduction and can develop fringing.
- Photographs saved as PNG — consider lossy palette reduction, or switch format entirely. A photo in PNG is usually the wrong container; JPEG or WebP will be far smaller for the same perceived quality.
- Images with gradients — lossy reduction risks banding. Check the preview carefully.
RIOT's automatic optimization classifies photos versus drawings, measures texture, and estimates how much quality is already in the file, then picks lossless, near-lossless, or lossy encoding and a quality level. You can override any of it manually.
Judging the result before you commit
The only reliable way to know whether an optimization went too far is to look at the output. A curtain-style compare view — original on one side, optimized on the other, with a draggable divider — lets you pan and zoom into the areas most likely to break:
- Flat color regions — look for banding where a smooth gradient used to be.
- Sharp edges and text — look for jagged or fuzzy edges.
- Transparent boundaries — look for halos or fringing where the image meets transparency.
- Fine texture — look for smearing or loss of detail.
RIOT's preview follows your current format and quality settings, including animated frames, so you can judge before writing anything to disk. This matters more for lossy settings than lossless ones, where the risk is near zero.
Batch optimization in practice
When you have a folder of PNGs rather than one file, a few things make the job manageable:
- Parallel processing — RIOT runs one optimization worker per CPU core, so a folder finishes in parallel instead of one file at a time.
- Live, cancellable progress — you can see where the batch is and stop it if the settings turn out wrong.
- A summary when it finishes — images processed, time elapsed, and bytes saved, so you know whether the effort paid off.
- A consistent preset — applying the same settings across a batch keeps results predictable, especially for a set of icons or screenshots that should match.
A practical workflow: test your settings on two or three representative files first, check them in the compare view, then run the full batch with the settings you've validated.
When PNG optimization isn't the answer
If a PNG is a photograph, no amount of lossless optimization will bring it close to what JPEG or WebP achieves. RIOT's "optimal format" option tries a smaller container and keeps the original when it already wins — useful when you're not sure whether PNG is the right choice for a given image. For photos, converting to a lossy format is usually the larger win; for graphics that need transparency and sharp edges, PNG remains the right container and optimization is the correct tool.