Find the colours that were already there
A photograph already contains a worked-out colour scheme: the light, the shadow and the subject agreed on it. The extractor groups the pixels into a handful of representative colours and hands you the hex codes, ready to paste into a site or a slide deck.
The Color Palette Extractor pulls a set of colours from a photo, or builds a palette from one base colour, and gives you the hex code for each. The colours are computed from the pixels in your browser, ready to copy into a design tool.
How it works
Add the image
Open the photo, screenshot or design you want colours from.
Choose the size
Pick how many colours the palette should have.
Take the codes
Copy the hex values or save the palette.
Dark to light, just like the picture: a near-black sky, a slate horizon, a violet glow, a warm blush and a pale sand highlight. Five colours are enough for a whole landing page.
Grouping thousands of pixels into five
The tool shrinks the picture to a few hundred pixels, throws away fully transparent ones, and then runs k-means: it picks a few starting colours, assigns every pixel to the nearest one, moves each colour to the average of its group, and repeats until nothing moves.
The weighting is perceptual rather than naive: green counts more than red in the distance calculation, because the eye is more sensitive to it and a straight RGB average would blur greens into browns.
The result is ordered by how much of the picture each colour covers, so the most important colour is first. That is a reasonable starting point for a scheme, though the colour you want as an accent is often the smallest group rather than the largest.
- check_circle4 colours for a simple interface
- check_circle6 for a landing page or a poster
- check_circle8 to 10 for an illustration or a chart set
Turning a palette into a usable scheme
The darkest colour for a dark interface, the lightest for a light one. Everything else is read against it, so it should be a quiet value.
Two steps away from the background in brightness, and check the contrast ratio: 4.5:1 for body text is the accessibility floor.
The most saturated colour in the set. Use it for buttons and links only, so it keeps meaning something.
What the exports contain
| Export | Format | Use it for |
|---|---|---|
| CSS variables | --color-1: #0b1020; | Pasting straight into a stylesheet |
| JSON | hex, rgb and hsl per colour | Design tools, scripts, Figma plugins |
| Click a swatch | Hex on the clipboard | Quick paste into any colour field |
| Base colour mode | Tints and shades | Building a scale around a brand colour |
Which colour should be the accent?expand_more
Usually not the most common one. The dominant colour is what the picture is made of — sky, skin, wall — and it works as a background. The accent is the small, saturated outlier: the red of a jacket, the teal of a sign. Look at the swatches with the lowest share and the highest saturation.
Why do the colours look slightly different from the photo?expand_more
Each swatch is the average of a group of pixels, so it is by definition a colour that exists between several. That is what makes it usable as a flat fill: a group average is calmer than a single sampled pixel, which may be noise.
What does the base colour mode do?expand_more
It ignores any picture and builds a scale around one colour, rotating the hue slightly and moving lightness from dark to light. Use it when you have a brand colour and need backgrounds, borders and hover states that belong to it.
Can I use a transparent PNG?expand_more
Yes. Fully transparent pixels are skipped, so the palette describes the artwork rather than the empty corners of the canvas.
Colour questions, answered
Is the image uploaded?expand_more
How many colours should I extract?expand_more
Does it remove the background before sampling?expand_more
Can I get matching darker and lighter versions?expand_more
Are the values CMYK or Pantone?expand_more
Is it free to use the palette?expand_more
How to Build a Colour Scheme From a Photograph
Most colour schemes fail for the same reason: they are chosen in isolation. A brand colour is picked from a mood board, then a background, then a text colour, and the three never spend a moment in the same picture. Photographs do not have this problem. A landscape at dusk is a palette that has already survived the light, the atmosphere and the eye of the person who took it, which is why extracting colour from an image is a better starting point than inventing it.
The extraction itself is a clustering problem. Every pixel of a picture is a point in a three-dimensional space of red, green and blue. The task is to place a small number of representative points — five, six, eight — so that every pixel is close to one of them. K-means does this by iteration: choose starting points, assign each pixel to the nearest, move each point to the average of its cluster, repeat. After a few rounds the points stop moving and the palette exists.
Why the distance calculation is not plain RGB
A naive implementation averages red, green and blue equally, which does not match human vision. The eye is most sensitive to green, then red, and least to blue, so the distance formula weights them roughly 0.3, 0.59 and 0.11. Without those weights, greens drift toward brown and skin tones toward grey, and the palette looks muddier than the photograph.
The other trick is sampling. Two hundred thousand pixels carry no more information about the palette than three thousand do, and k-means cost grows with the number of points. Shrinking the image and stepping through it produces the same result in a fraction of the time.
From palette to interface
A scheme needs three roles before it needs ten colours. The background is the quietest value — the darkest swatch for a dark interface, the lightest for a light one. The text colour sits at least two brightness steps away from it, and the contrast ratio between them should reach 4.5 to 1 for body text; anything less is unreadable in daylight on a phone. The accent is the most saturated colour of the set, reserved for buttons, links and one or two highlights.
The remaining colours do the supporting work: borders, hover states, chart series, illustration fills. A palette of six usually resolves into two backgrounds (page and card), two text values (primary and secondary) and two accents. That is a complete interface, and it came from a single photograph.
Practical rules that save you later
- Extract from the part of the picture you actually like — crop out that distracting foreground first.
- Trust the order: the largest group is usually a background, not an accent.
- Never use two accents of similar saturation next to each other; the eye cannot tell which one is the action.
- Test the palette on a screenshot, not on a swatch page. Colours behave differently when they hold text.
Finally, keep the source. Write the hex codes into your stylesheet as named variables and note which photograph they came from. Six months later, when you need a seventh colour, you can go back to the same picture and extend the scheme instead of guessing at a new one.
Contrast is the part a palette cannot fix by itself
A pair of colours that looks lovely on a swatch page can be unreadable as text. Contrast is a ratio between the relative luminance of two colours, and the guideline for body text is 4.5 to 1; large headings can go down to 3 to 1. The practical consequence is simple: whatever the photograph gives you, the text colour is usually not one of its saturated tones but a near-black or near-white derived from the background.
That is why a palette of six works better as two backgrounds, two text values and two accents than as six equally weighted colours. When a brand insists on coloured text, keep it for short labels and put the paragraphs in the neutral value.
Keeping a palette alive
Colours drift. A new image on the home page, a seasonal banner, one designer's monitor calibrated differently, and within a year the site has nine greens. The defence is boring and effective: name the variables in the stylesheet, forbid raw hex codes in components, and review the palette twice a year against a single reference image. A palette that is documented survives; one that lives in a mood board does not.
It is also worth recording the source photograph and the extraction settings next to the variables. When the next person needs a colour for a hover state, they can reproduce the same palette in a minute instead of inventing a tenth green.
More image tools for designers
fact_checkQuick facts
- A palette sampled from a photo reproduces its mood; a palette generated from one colour is built for contrast and consistency.
- WCAG AA asks for a contrast ratio of 4.5:1 for body text, which is the number to check before pairing two colours from a palette.
- An untagged image is assumed to be sRGB, so a picture in Display P3 looks duller once its profile is dropped.menu_bookInternational Color Consortium
- Stripping metadata and stripping the colour profile are two different operations: the first removes privacy data, the second changes colour.menu_bookInternational Color Consortium
- The canvas specification defines toBlob and toDataURL for exporting the drawing, and the format and quality are chosen at export time.menu_bookWHATWG
helpQuestions people ask
How do I get a colour palette from a photo?expand_more
What contrast ratio should text on a colour have?expand_more
Why do my palette colours look different on screen and in print?expand_more
hubWhat this page is about
- ICC colour profileopen_in_new
A file that describes how the colours of an image map to a device, defined by the International Color Consortium.
- Canvasopen_in_new
The HTML element that gives a page a pixel buffer to draw on and export as PNG, JPEG or WebP.
- PNGopen_in_new
A lossless image format defined by the W3C with an 8-bit alpha channel and gamma information, designed for the web in 1996.
library_booksOfficial sources cited on this page
- ICC colour profile specificationsInternational Color Consortium
- HTML Living Standard (canvas, file input, media elements)WHATWG
- PNG (Portable Network Graphics) Specification, Third EditionW3C
Continue with the same file
Each of these opens what the tool above produces. Use “Use in another tool” under the result to carry the file over — it moves from tab to tab inside your browser, never to a server.
Switched-off tools are not listed here: only what works right now.