How to Compress a PNG Without Losing Quality
Step-by-step guide to reducing PNG file sizes with zero quality loss — covering deflate optimisation, metadata stripping, palette reduction, and WebP conversion.
Why "compressing a PNG" can mean very different things
Search for "compress PNG" and you will find tools that do wildly different things. Some apply true lossless optimisation — your pixels are unchanged. Others quietly convert to JPEG, reduce the bit depth, or apply lossy quantisation to the colour palette. These produce smaller files, but at a cost you may not notice until you zoom in.
This guide covers only genuinely lossless techniques: methods that produce a smaller PNG (or equivalent lossless format) that decompresses to pixel-for-pixel identical content.
Technique 1: Maximise DEFLATE compression
PNG uses DEFLATE compression internally, but most image editors save at a mid-level compression setting (typically level 6 out of 9) because maximum compression takes longer. The pixels are identical either way — only the encoding efficiency differs.
Re-encoding at maximum DEFLATE (level 9) or using Zopfli (a DEFLATE-compatible algorithm that finds shorter encodings at the cost of more CPU time) typically saves 3–8% compared to a file saved by a standard image editor. It is small but entirely free — no quality change, no format change, just a better-packed zip-like container around the same pixel data.
Technique 2: Optimise prediction filters
Before DEFLATE runs, PNG transforms each row of pixels using a prediction filter — the encoder stores the difference between each pixel and a prediction based on its neighbours, rather than the raw pixel value. Small differences compress better than large raw values.
The PNG spec defines five filter types, and the encoder can choose differently for each row. Many encoders use a single fixed strategy. A dedicated optimiser tests multiple strategies and keeps whatever produces the smallest result. This alone can save 5–15% on typical screenshots and graphics.
Technique 3: Strip metadata
PNG files can contain numerous auxiliary data chunks: text comments, creation timestamps, software identification, embedded ICC colour profiles (often large), EXIF data, and more. For web delivery, most of this is irrelevant. Stripping non-essential chunks is safe and can save 5–50 KB on files where software like Photoshop or Figma has embedded verbose metadata.
Note: if accurate colour rendering matters — for example, professional photography or design files distributed to clients — keep the ICC profile. For most web images, browser default colour handling is fine without an embedded profile.
Technique 4: Reduce bit depth (for eligible images)
A standard PNG stores 8 bits per channel (24 bits for RGB, 32 bits for RGBA). If an image uses 256 or fewer distinct colours, it can be stored as an 8-bit palette PNG with no information loss. Many icons, logos, and simple illustrations qualify. Palette-mode PNG files are typically 40–60% smaller than 24-bit equivalents for the same content.
This is technically lossless — every pixel's colour is preserved exactly — but the palette must be built from colours actually present in the image. If the tool adds any quantisation (rounding nearby colours to a single palette entry), it becomes lossy. Verify by comparing the original and compressed pixel values before assuming it is lossless.
Technique 5: Convert to lossless WebP
WebP lossless uses a more sophisticated compression pipeline than PNG: it includes colour transforms, a subtract-green channel transform, backward references, and multi-dimensional Huffman coding. The result is that WebP lossless is typically 15–25% smaller than an equivalent PNG, for identical pixel content.
The trade-off is compatibility. WebP is supported by all modern browsers (Chrome, Firefox, Safari 14+, Edge), but older environments may not support it. For web delivery in 2025, WebP lossless is a solid choice for any image where PNG was previously used.
What to avoid
Several common "PNG compressors" actually apply lossy techniques without being explicit about it:
- Lossy palette quantisation: Reducing a 24-bit PNG to 8-bit by merging similar (but not identical) colours. This is lossy — pixels change value. Tools like TinyPNG do this, and it is often imperceptible, but it is not lossless.
- Converting to JPEG: Some "compress PNG" tools silently save as JPEG for photographs. The file may be smaller, but it is no longer a PNG and is no longer lossless.
- Resizing: Reducing image dimensions reduces file size dramatically but obviously changes the image.
A practical workflow
- Start with your original PNG at full quality.
- Apply lossless optimisation (maximised DEFLATE + filter optimisation + metadata stripping).
- If the image has 256 or fewer colours, test palette reduction and verify the result is visually identical at the pixel level.
- Test lossless WebP conversion — keep whichever is smaller, provided WebP is acceptable for your use case.
- Never re-edit a previously optimised PNG and re-save through an image editor — this re-applies the original (suboptimal) encoder settings.
Compressanimage.com applies steps 1 and 4 automatically — it tests both optimised PNG (maximum DEFLATE) and lossless WebP, then serves whichever is smaller. Drop your files in and see the savings with zero quality loss.