What this image color picker does
It does two jobs. The picker reads the exact color of one pixel, like the eyedropper in an image editor. The palette extractor looks at the whole picture and finds the few colors that cover most of it, with a percentage for each.
Everything happens in your browser. The file is decoded onto a canvas on your device and nothing is uploaded. Your picked colors are kept in this browser's local storage so they survive a reload; the image itself is not stored.
How picking works
The image is drawn onto a canvas at its full resolution, and a pick reads the red, green, blue and alpha values of the pixel under the pointer. The image on screen is usually scaled to fit, so one screen point can cover several image pixels; the magnifier shows the real pixels around the pointer so you can aim at a single one. Very large images (over 16.7 million pixels, for example 5000 × 4000) are scaled down to that size first, because some browsers limit how large a canvas can be; the page tells you when this happens.
The canvas stores colors in sRGB, so browsers normally convert an image with an embedded color profile to sRGB when they draw it, and the values are the ones CSS would use. Colors in wide-gamut photos (Display P3, for example) that lie outside sRGB may be clipped.
How the dominant colors are found
- Downsampling. Images larger than 512 pixels on the longest side are scaled down to 512 for the analysis. That keeps it fast and barely changes the result, because the palette describes large areas, not single pixels. Picking still uses the full-resolution image.
- Skip transparency. Fully transparent pixels are ignored. Partly transparent pixels count in proportion to their opacity, so a 50% transparent pixel counts as half a pixel.
- Group similar pixels. Colors are collected into 32,768 small bins (5 bits per channel), each holding the average of the real colors that fell into it.
- Cluster in OKLab. The bins are clustered with weighted k-means in OKLab, a color space designed so that equal distances look about equally different. Starting points are chosen with k-means++ from a fixed random seed, so the same image and settings always give the same palette.
- Report. Each cluster's average color becomes a palette entry, and its share is the weight of its pixels divided by the weight of all non-transparent pixels. Entries are sorted from largest share to smallest.
Worked example: the sample image
The sample is a flat-color landscape of 480 × 320 pixels with a transparent top-right corner. With 6 colors, the extractor returns:
| Color | HEX | Share |
|---|---|---|
| Sky | #8ECAE6 | 42.0% |
| Near hill | #264653 | 25.4% |
| Far hill | #2A9D8F | 13.1% |
| Sand | #E9C46A | 9.9% |
| Lake | #219EBC | 7.4% |
| Sun | #FFD166 | 2.1% |
These are exactly the six colors the sample was drawn with, and the shares are their areas; the transparent corner does not count. With only 3 colors, similar areas have to share a cluster: the sky, sand and sun merge into #A6CBCE (54.0%), the two blue-green areas into #269EA0 (20.6%), and the dark hill stays #264653 (25.4%). A merged color can be one that appears nowhere in the image, so choose more colors when you need the real ones.
Picking the sun gives #FFD166, rgb(255, 209, 102), hsl(42, 100%, 70%) and oklch(88.03% 0.1348 86.06). Its nearest CSS name is khaki (#F0E68C), at a deltaE OK of 0.054.
Exports
- CSS variables: a
:rootblock such as--palette-1: #8ecae6;, ready to paste into a stylesheet. - JSON: an array with HEX, RGB, HSL and OKLCH for each color, plus the share in percent for dominant colors.
- HEX list: one code per line, for design tools that accept a list.
Common mistakes
- Picking from a screenshot of a photo. JPEG compression and resizing change pixel values, so neighboring pixels in a flat area can differ by a few steps. Use the original file, and check a few nearby pixels with the magnifier.
- Expecting the largest color to be the most important. Backgrounds usually win on share. A small but strong accent color may need a higher number of colors to show up.
- Using a palette color for text without checking it. Colors taken from photos often have low contrast against white or black. Check pairs with the contrast checker before using them for text.
- Forgetting transparency. A pixel in a transparent PNG can have any RGB value behind zero alpha. The picker tells you when a pixel is fully transparent instead of reporting a color you would not see.