Extract dominant colours from a photo and copy hex values in one tap for palette reference
The screenshot below was taken in this tool with a real file and the stated settings — it is not a mock-up.
Extraction uses K-means clustering. Treat every pixel colour as a point in 3D space, place K random centres, then repeatedly assign each point to its nearest centre and recompute the centres until they settle.
The K settled centres are the image's K dominant colours. For stability the algorithm samples (large images are not computed pixel by pixel) and iterates 12 times.
Finally the colours are sorted by luma (0.299R + 0.587G + 0.114B) from dark to light, ready to use as a palette strip.
It works best for:
Pull a palette from a reference image straight into your design
Extract brand colours from a company logo or product shot
Take dominant colours from a photo to match furnishings or clothing
Grab HEX values quickly for your CSS
| Input format | PNG / JPG / WebP / GIF / BMP / SVG / AVIF / ICO / HEIC |
|---|---|
| Number of colours | Adjustable from 3 to 16 |
| Algorithm | K-means clustering (12 iterations, auto-sampling) |
| Output values | HEX and RGB — click to copy |
| Ordering | By brightness, dark to light |
K-means starts from random centres, so repeated runs on the same image can differ slightly. Try a different count, or run it a few times and keep the colours that appear consistently.
Clustering is driven by pixel counts, so colours with a tiny share (a small highlight, say) may not form their own cluster. Increase the number of colours in that case.
No. Pixels below 50% opacity are skipped, so only visible parts are sampled.
This version only copies values. For an image, take a screenshot or merge the swatches with the Merge tool.
This is k-means clustering over sampled pixels. The image is sampled on a grid whose step is max(1, floor(sqrt(width × height / 4000))), which targets roughly 4,000 samples regardless of image size; images smaller than that are sampled completely. Each sample is a point in RGB space with no weighting by position or by area beyond the sampling itself. Transparent pixels — alpha below 128 — are skipped entirely, so a PNG with a large transparent margin does not waste palette slots on nothing.
The algorithm then places the requested number of centres at random sample positions and runs twelve reassignment passes. That random start is the reason two runs on the same file can differ by a shade or two: k-means converges to a local solution, and a different start can land in a different one. Running the extraction twice and keeping the colours that appear in both is a cheap way to separate the stable palette from the noise.
If a cluster loses all its members during a pass, the implementation keeps the previous centre instead of reseeding it. On a flat image — a logo on a single background — several centres can end up parked on the same colour, producing identical hex values in the list. That is not a colour-picking bug; it is the honest answer that the requested count exceeds the number of distinct colours the image contains. Reduce the count to 3–5 for flat graphics and the duplicates disappear.
Clusters are sized by how many samples fall into them, so a large area of sky dominates a small area of red signage. That is statistically correct and often wrong for design work: the colour you want is frequently the smallest accent in the frame. Two adjustments help. Crop to the region that matters before extracting, using Crop Image, so the sampling grid is spent on the subject. Or increase the count to 12–16 and ignore the top of the brightness-sorted list.
The list is ordered by brightness, dark to light, not by population. A near-black and a near-white often occupy the two ends regardless of how much of the image they cover.
The output is a set of hex and RGB values; no image is re-rendered and no palette file is produced. Two practical gaps follow. First, a cluster centre is an average, so a vivid object photographed with soft light yields a desaturated hex that looks duller than the object. Second, the average of an area containing both shadow and highlight is often a mid-tone that exists nowhere in the picture. For interface work, treat the extracted value as a starting point, then check contrast against the actual background — a mid-tone sampled from a photo rarely passes 4.5:1 against white.
Copying is one click per swatch, and the "copy all" button writes the hex values as newline-separated text, which pastes cleanly into a design token file or a CSS variable block.