PNG to PNG8 Converter
Convert PNG32/PNG24 images to PNG8 (indexed 8-bit) with full alpha transparency. Median cut quantization, optional dithering, batch processing.
About
PNG8 (indexed-color PNG) stores each pixel as an index into a palette of up to 256 colors, reducing file size by 60 - 80% compared to PNG32. The critical challenge is alpha preservation. Standard tools often discard the alpha channel during quantization, producing hard-edged cutouts against colored mattes. This converter implements median cut quantization across the full RGBA color space and writes a per-entry tRNS chunk, maintaining smooth semi-transparent edges. Getting color reduction wrong means visible banding, posterization, or complete loss of transparency data - problems that cascade through responsive image pipelines and inflate bandwidth costs on mobile networks.
The quantization algorithm partitions the 4-dimensional RGBA cube by iteratively splitting the longest-axis bucket at its median. Optional Floyd-Steinberg dithering diffuses quantization error to neighboring pixels, trading spatial noise for perceptual smoothness. Note: this tool approximates optimal quantization. For images with more than 256 perceptually distinct colors, some detail loss is inherent to the 8-bit format. Pro tip: reduce your source image to the target display size before converting to minimize palette waste on subpixel color variations.
Formulas
The median cut algorithm operates in 4-dimensional RGBA space. Each pixel p is a vector (r, g, b, a). The color space is recursively partitioned into k buckets (where k ≤ 256) by splitting the bucket with the largest range along its longest axis at the median value.
The palette color for each bucket is the weighted mean:
Floyd-Steinberg dithering distributes quantization error e = poriginal − pquantized to four neighboring pixels with weights:
Where B = color bucket, Cj = palette color for bucket j, p = pixel RGBA vector, e = quantization error vector, k = target palette size, |Bj| = number of pixels in bucket j.
Reference Data
| PNG Type | Color Type | Bit Depth | Max Colors | Alpha Support | Typical File Size (1000×1000) | Use Case |
|---|---|---|---|---|---|---|
| PNG8 Indexed | 3 | 8 | 256 | tRNS chunk (per-palette) | 50 - 150 KB | Icons, logos, UI sprites |
| PNG24 Truecolor | 2 | 8 | 16,777,216 | None | 200 - 800 KB | Photos without transparency |
| PNG32 Truecolor+Alpha | 6 | 8 | 16,777,216 | Full 8-bit alpha channel | 300 - 1200 KB | Photos with transparency |
| PNG1 (1-bit) | 3 | 1 | 2 | tRNS chunk | 5 - 20 KB | Monochrome icons, fax |
| PNG2 (2-bit) | 3 | 2 | 4 | tRNS chunk | 10 - 40 KB | Simple graphics |
| PNG4 (4-bit) | 3 | 4 | 16 | tRNS chunk | 20 - 80 KB | Low-color icons |
| Grayscale PNG | 0 | 8 | 256 shades | tRNS (single value) | 80 - 300 KB | Medical imaging, masks |
| Grayscale+Alpha | 4 | 8 | 256 shades | Full 8-bit alpha | 150 - 500 KB | Shadows, overlays |
| APNG (Animated) | 6 | 8 | 16,777,216 | Full 8-bit alpha | 500 - 5000 KB | Animated stickers |
| PNG Interlaced | Any | Any | Varies | Varies | +10% overhead | Progressive loading |
| Compression Level 0 | Any | Any | Varies | Varies | Largest | Speed priority |
| Compression Level 9 | Any | Any | Varies | Varies | Smallest | Size priority |
| WebP Lossy | N/A | N/A | 16.7M | Yes | 30 - 100 KB | Web photos (alternative) |
| WebP Lossless | N/A | N/A | 16.7M | Yes | 100 - 400 KB | Web graphics (alternative) |
| GIF | Indexed | 8 | 256 | 1-bit (on/off) | 60 - 200 KB | Legacy animation |