Renchao Wu · byte-by-byte encoding · v0.1.0
PNG Row Filter Desk
Six PNG encodings. Exactly the same RGBA bytes.
Inspect None, Sub, Up, Average, Paeth and a row-score heuristic. See each byte's predictor, wrapped residual and reconstruction, then download actual PNGs. A smaller row score does not guarantee the smallest compressed file.
Source pixels
Exactly {width,height,rgba}. The array is row-major R,G,B,A with four integer bytes per pixel. Alpha is unpremultiplied; invisible RGB values are retained in the encoded bytes. Ctrl+Enter encodes.
Loading original examples…
Preparing six encodings…
Measured sizes, same source
Sizes are measured from this runtime's actual zlib outputs. Every file has 57 bytes of PNG structure plus IDAT data. Different engines may compress differently; these are neither canonical compressed bytes nor a universal ranking.
Inspect an encoding
Checkerboard shows transparency. Previews reflect browser color/compositing behavior. Byte equality is checked by reconstructing the filtered stream, including invisible RGB, rather than reading color-managed preview pixels.
Every row and its five scores
Scores sum absolute signed residual bytes. A type byte prefixes each row but is excluded from its score. Heuristic ties choose the lowest filter type.
Every byte, reconstructed
For RGBA8, the left neighbor is four bytes earlier, in the same channel. Previous-row neighbors use original values while filtering and reconstructed values while decoding. Missing neighbors are zero. Average uses a wide sum and floor division; Paeth ties prefer left, then up, then upper-left. Residuals wrap modulo 256.
Full JSON retains all six encodings, every row/byte, source and reconstructed bytes, scanlines, IDAT bytes, complete PNGs, chunk CRCs and hashes. This display's filters and pages never truncate it. CSV contains all rows of the selected encoding only.
What the heuristic can miss
The row-score rule makes local choices. DEFLATE compresses the complete sequence of filtered rows, including type bytes, so a fixed filter can produce a smaller PNG. All six results, ties and losing heuristic cases stay visible. The supplied examples were fixed before compression results were measured.
This original implementation follows W3C PNG filtering. It uses standard algorithms and the platform's actual CompressionStream API, with no learned model or new compression algorithm.