User Rating 0.0
Total Usage 0 times
Drop PNG files here or click to browse Supports PNG24 & PNG32 • Max 50 MB per file
256
128
Is this tool helpful?

Your feedback helps us improve.

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.

png to png8 png8 converter color quantization reduce png colors indexed png alpha transparency png8 image optimization median cut

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.

range(B) = maxc(Bmax,c Bmin,c) for c {r, g, b, a}

The palette color for each bucket is the weighted mean:

Cj = 1|Bj| p Bj p

Floyd-Steinberg dithering distributes quantization error e = poriginal pquantized to four neighboring pixels with weights:

716 right, 316 below-left, 516 below, 116 below-right

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 TypeColor TypeBit DepthMax ColorsAlpha SupportTypical File Size (1000×1000)Use Case
PNG8 Indexed38256tRNS chunk (per-palette)50 - 150 KBIcons, logos, UI sprites
PNG24 Truecolor2816,777,216None200 - 800 KBPhotos without transparency
PNG32 Truecolor+Alpha6816,777,216Full 8-bit alpha channel300 - 1200 KBPhotos with transparency
PNG1 (1-bit)312tRNS chunk5 - 20 KBMonochrome icons, fax
PNG2 (2-bit)324tRNS chunk10 - 40 KBSimple graphics
PNG4 (4-bit)3416tRNS chunk20 - 80 KBLow-color icons
Grayscale PNG08256 shadestRNS (single value)80 - 300 KBMedical imaging, masks
Grayscale+Alpha48256 shadesFull 8-bit alpha150 - 500 KBShadows, overlays
APNG (Animated)6816,777,216Full 8-bit alpha500 - 5000 KBAnimated stickers
PNG InterlacedAnyAnyVariesVaries+10% overheadProgressive loading
Compression Level 0AnyAnyVariesVariesLargestSpeed priority
Compression Level 9AnyAnyVariesVariesSmallestSize priority
WebP LossyN/AN/A16.7MYes30 - 100 KBWeb photos (alternative)
WebP LosslessN/AN/A16.7MYes100 - 400 KBWeb graphics (alternative)
GIFIndexed82561-bit (on/off)60 - 200 KBLegacy animation

Frequently Asked Questions

PNG8 uses a tRNS chunk that assigns an alpha value (0-255) to each palette entry independently. Each of the 256 palette slots can have a unique alpha level. This means semi-transparent pixels are supported, but each unique combination of (R, G, B, A) consumes one palette slot. If your image has many distinct semi-transparent colors, some will be merged during quantization.
The median cut algorithm clusters similar colors together and replaces each cluster with its average color. Visually similar colors merge. If your source has thousands of distinct colors (common in photographs or gradients), you will see posterization - visible bands where smooth gradients existed. Enabling Floyd-Steinberg dithering adds noise that breaks up these bands, trading sharpness for perceptual smoothness. For photographic content, consider PNG8 only for thumbnails under 200×200 pixels.
Yes. PNG8 uses DEFLATE compression on indexed pixel data. Fewer distinct index values means more repetitive byte sequences, which DEFLATE compresses more efficiently. Reducing from 256 to 64 colors typically yields an additional 15-30% file size reduction depending on image complexity. The relationship is not linear because DEFLATE exploits spatial patterns, not just value cardinality.
White halos occur when the alpha threshold is too aggressive - pixels with partial transparency (alpha 128-250) get forced to fully opaque against a white matte. Lower the alpha threshold slider to preserve more semi-transparent values in the tRNS chunk. Alternatively, increase the palette size to give the quantizer more slots for semi-transparent color variants.
Dithering increases file size by 10-40%. The error diffusion pattern introduces high-frequency noise into the pixel data, reducing spatial redundancy that DEFLATE relies on. For flat-color graphics like logos and icons, disable dithering. For images with gradients or photographic regions, dithering is usually worth the size trade-off because the visual improvement is significant.
Yes. If the source is already a PNG8, the converter decodes it to full RGBA pixel data first (via Canvas drawImage), then re-quantizes with your specified palette size and settings. This is useful for re-optimizing legacy PNG8 files with suboptimal palettes or for reducing a 256-color palette down to 64 or 32 colors.