← Back to Hub

Pixel Extract & Compress

Reduce an image to a small colour palette, store each pixel as a palette index, and compress the indices with run-length encoding. Every result is decoded again and checked pixel-for-pixel. Works offline; images never leave your device.

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
  1. Resize (optional) with nearest-neighbour sampling so the result is true pixel art.
  2. 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).
  3. 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.
  4. 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

Source
Pixel map (decoded)
Statistics appear after mapping.