1. Image & settings
…or drop an image here, or load a map (.json) to decode it.
Dithering looks smoother but creates fewer long runs, so it compresses less.
Choose an image to start.
How it works / format
- Resize (optional) with nearest-neighbour sampling so the result is true pixel art.
- Median cut (Heckbert, 1982): the set of colours is repeatedly split at the weighted median of its widest channel until there are N boxes; each box's pixel-weighted average becomes a palette colour. Pixels are then mapped to the nearest palette colour (squared RGBA distance), optionally with Floyd–Steinberg error diffusion (7/16, 3/16, 5/16, 1/16).
- PackBits RLE on the index bytes (row-major), as specified for TIFF (TIFF 6.0, section 9): header byte n 0…127 → copy the next n+1 bytes literally; n −1…−127 (129…255) → repeat the next byte 1−n times; −128 is a no-op.
- Verification: the encoded stream is decoded and compared with the original indices; the status line says “round trip verified” only if all w×h bytes match.
JSON map: {"format":"pixel-map/1","width","height","palette":["#rrggbbaa",…],"encoding":"packbits","data":"<base64>"}. Palette is limited to 256 colours because each index is one byte.
2. Result
| Statistics appear after mapping. |