← Back to Home

How PNG Compression Works

A practical overview of the PNG format and the techniques used to reduce file size.

Quick Summary

  • PNG uses lossless compression (DEFLATE) with optional pre-compression filters.
  • Optimizations focus on reducing entropy via filtering, palette reduction, and metadata removal.
  • Great for graphics, UI, screenshots, logos, and transparency.

PNG Building Blocks

PNG files are composed of typed chunks such as IHDR (header), PLTE (palette), IDAT (image data), and IEND (end). The image data is compressed using the DEFLATE algorithm. Before compression, PNG applies per-row filters to transform pixel values into differences that compress better.

Filters

PNG supports five filters: None, Sub, Up, Average, and Paeth. Each filter predicts the next pixel from neighbors and stores only the difference. Encoders choose the best filter per row to maximize compressibility.

Color Types and Palettes

PNG supports truecolor (RGB/RGBA), grayscale, and indexed color via palettes. When possible, converting to an indexed palette can significantly reduce size while remaining lossless. This is especially effective for logos and UI art with a limited color set.

Metadata and Ancillary Chunks

Many PNGs contain optional chunks (textual data, time, gamma, ICC) that are not required for display. Removing unnecessary metadata reduces file size without affecting visual output.

Practical Tips

  • Prefer PNG for graphics with flat colors or transparency. Consider JPEG/WebP/AVIF for photos.
  • Use palette reduction where suitable. Keep alpha channel only if you need transparency.
  • Strip non-essential metadata.

Next Steps

Learn about trade-offs in Lossy vs Lossless Compression, or dive into PNG Optimization Best Practices. When ready, try batch workflows with our Batch Compression Guide.