Color Palette Generator
Published Updated
Upload a photo to get its five most common colors as swatches with HEX, RGB and HSL on click, or click any pixel for its exact value. About 20,000 pixels are sampled in 16-level buckets, so a smooth sky can give five similar blues.
What the sampling does
For an image of N pixels, the page reads every (N / 20,000)th pixel, rounded down, so a 12 megapixel photo is read at every 600th pixel and a small icon is read in full. Each sampled pixel's red, green and blue are cut to their top four bits to make a bucket key. Counts decide the order, and the mean of the original values decides the color shown. The values come from the canvas through getImageData, which MDN lists as 8 bits per component in the default pixel format, so every channel is a whole number from 0 to 255.
Three test images
Synthetic images drawn on a canvas, run through a copy of the page's function in Google Chrome 156:
| Image | Result |
|---|---|
| Flag: red 50%, white 30%, blue 20% | #C8102E, #FFFFFF, #003893 with 10,000, 6,000 and 4,000 samples; only 3 buckets |
| Dark blue to pale blue gradient | #174898, #A8C6E9, #87A9D7, #3965AB, #BAD6F3; 30 buckets |
| Grey with a 3% orange square | #E8E8E8 with 19,400 samples, #FF3300 with 600 |
Flat colors come back exactly. Gradients return averages, which look like the area but may not exist as a pixel.
Pulling a palette
Step 1
Add an image
Any type the browser can draw. The picture is drawn at full size on a canvas, and the palette is computed from it right away.
Step 2
Click a swatch or the picture
A swatch opens HEX, RGB and HSL with a copy button for each. Clicking the picture picks the pixel under the pointer, and a loupe magnifies it six times while you hover.
Step 3
Reset to use another image
Nothing is saved. Reset clears the picture and the swatches.
Related tools
- To turn a swatch into other notations, paste its HEX into Color Converter.
- The exact-pixel pick works like the one in Color Picker, which is the same tool under a different page.
Palette questions
How does it choose the five colors?
It samples about 20,000 pixels spread through the image, sorts each into one of 4,096 buckets of 16 levels per channel, and returns the five fullest buckets. The swatch is the average of the sampled pixels in its bucket.
Why are my five colors all similar?
Buckets are not merged by closeness. A gradient fills many neighbouring buckets, so a blue-to-white sky test gave five blues. Pick from different areas with the eyedropper if you need contrast.
Why is a small accent color missing?
Only the five commonest buckets count. An orange square covering 3% of an otherwise grey picture ranked second, but on a busy photo it would be outvoted by larger areas.
What happens to transparent areas?
Pixels with alpha below 125 are skipped. In a test image with the right three quarters transparent, only the opaque red counted.
Is the result the same each time?
Yes for a given image. The pixels are sampled at fixed intervals, with no random choice, so the swatches repeat.
Is my photo uploaded?
No. Decoding and the color arithmetic both run on your device, and nothing is sent.