Image palette & quantiser
Extract an image's dominant colours with median-cut quantisation (hex list with shares) and reduce the image itself to 2–256 colours, then export PNG or JPEG.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Images are processed locally in your browser with Canvas and never uploaded.
2–256; median-cut quantisation derives that many representative colours and maps every pixel to one.
Pick an image first (PNG / JPEG / WebP / GIF all work).
Result details
Pick an image and its palette is extracted with the quantised result shown right away.
What this tool does
- Pull the dominant colours: get a hex list with the share of each colour for design references or brand checks.
- Colour reduction: quantise a photo to 16–64 colours so the PNG shrinks noticeably — handy for low-bandwidth or retro looks.
- Consistent styling: quantise several assets to the same colour count so they sit together with one tone.
- Different from the pixel-art tool: this one only quantises colours (same size), while pixel art also downscales into a pixel grid.
Example
Input
A 4×4 image with four flat colours (red, green, blue, yellow) of 4 pixels each and target 4 colours
Output
A palette of 4 colours at 25% each: #ff0000, #00ff00, #0000ff, #ffff00
The pure extractPalette logic skips fully transparent pixels before counting, and buildPalette runs median cut, returning entries in descending usage order. Quantising to 2 colours yields exactly 2 colours and pixels different from the source.
Frequently asked questions
How is the palette computed?
Median cut: the widest channel of the current colour set is found and split at its median, repeating until the target colour count is reached. Each bucket contributes its average colour, and entries are sorted by usage.
Which colour count should I choose?
It depends: 6–12 for palette extraction, 16–32 for an icon or illustration look, and 8–16 for hard compression of photos (which will band visibly). The range is 2–256 and out-of-range values report an error.
What happens to transparent pixels?
Pixels with alpha = 0 are skipped when building and mapping the palette (they contribute no colour) but stay transparent in the output — they are never filled. A fully transparent image has no colours to quantise and reports an invalid palette.
What does the sample step change?
Only the speed and precision of the statistics: step 1 uses every pixel while step 4 uses one in four. Steps of 2–4 speed up large images noticeably at a small cost in palette accuracy.
How is this different from the pixel-art tool?
This tool keeps the original dimensions and only remaps colours to the extracted palette. The pixel-art tool additionally shrinks the image to a coarse pixel grid and then enlarges it with nearest neighbour, so it changes the size as well.
Are my images uploaded?
No. Pixels are read through the canvas and processed entirely in the browser; there is no upload endpoint on the page.
Keywords:palette extractormedian cut