Colour palette from an image

CreativePull the main colours out of a photo or logo as hex codes, CSS or a GIMP palette, with a text-contrast check on each. In your browser: free, no upload.

Your picture is analysed on this device and never leaves it. Nothing you open is ever uploaded. There is no server to upload it to.

What this does

It finds the handful of colours that best describe a picture, a photo, a logo, a painting, a screenshot, and gives them to you in the forms you are likely to need: hex codes, CSS custom properties, a PNG card of the swatches, or a palette file for GIMP, Inkscape and Krita. Each colour shows how much of the picture it covers, and whether black or white text reads on it.

It runs in your browser. Nothing is uploaded, which matters for the unreleased logo, the client’s mock-up and the photo of your children alike.

How to use it

  1. Drop a JPEG, PNG or WebP onto the tool, or press “Choose an image”.
  2. Set how many colours you want with the slider. The palette updates as you drag, most used colour first.
  3. Click a swatch to copy its hex code, or use the buttons to copy every code, copy the palette as CSS, or download it as a PNG or a GIMP palette.
  4. To read the colour of one exact spot, click it on the picture.

How the colours are chosen, measured

A palette tool has to decide which few colours stand for thousands. This one groups the picture’s colours with k-means clustering in OKLab, a colour space built so that equal distances look equally different, and averages each group’s colours as light rather than as file numbers, for the reason the pixel-art converter explains: file numbers are not proportional to brightness, and averaging them darkens.

We measured how well the result represents the picture, on the 24 standard Kodak test photographs: for every part of each picture, how far its colour is from the nearest palette colour, judged by CIEDE2000, the industry’s standard formula for how different two colours look. Lower is better.

Colours This tool k-means on file numbers Median cut
5 6.60 6.69 7.30
8 5.17 5.27 5.87
12 4.21 4.31 5.08

Against median cut, the classic method, this tool’s palettes are 10 to 17% closer to the picture. Against plain k-means on the file’s numbers, the common approach, the gain is small, 1 to 2%, and it was the better palette on 14 to 17 of the 24 photographs rather than all of them. We would rather say so than round it up.

One more rule: colours nobody could tell apart are merged. Ask a one-red logo for two colours and clustering will dutifully find two reds a shade apart, so the tool folds anything closer than a just-noticeable difference into one swatch, and you get fewer colours than you asked for only when the picture really has fewer.

Transparency

Logos usually arrive as PNGs with transparent backgrounds, and a transparent pixel still stores a colour, often black, that nobody ever sees. Count it and the logo’s palette gains a black it does not have. This tool weights every pixel by how opaque it is, so see-through areas add nothing and half-transparent edges count half.

Contrast, checked

Under each swatch is the better of black or white text on that colour, and its contrast ratio by the formula in the web accessibility guidelines. A ratio of 4.5:1 or more is fine for body text; below it, keep that colour behind large headings. It is the quickest way to tell which of a photo’s colours can carry words.

Limitations

Up to twelve colours. More than that is less a palette than a posterised copy of the picture; the pixel-art converter goes up to 64.

Colours are as the file stores them. A photo of a painted wall gives the colour the camera recorded, which depends on the light it was taken in, not the paint’s name on the tin.

Frequently asked questions

How do I get a colour palette from an image?

Drop the picture onto the tool. Its main colours appear at once, most used first, each with its hex code and its share of the picture. Drag the Colours slider for more or fewer, click any swatch to copy its code, or take the whole palette as hex codes, CSS custom properties, a PNG card or a GIMP palette file.

How many colours should I extract?

Five or six describe most photographs and suit a brand or a website scheme. Go up to twelve when you want the supporting shades too, or down to two or three for the colours a logo is really built from.

Can I get the exact colour of one spot?

Yes. Click anywhere on the picture and the tool reads the colour at that exact point, with its hex and RGB values and a button to copy it. Useful for matching a logo's colour exactly rather than taking the palette's average of an area.

What does the contrast label under each colour mean?

It says whether black or white text reads better on that colour, and by how much, as the contrast ratio the web accessibility guidelines (WCAG) use. 4.5:1 is the minimum for normal text; below that, the colour is safe for large headings only.

Does it work with logos on transparent backgrounds?

Yes. Transparent areas are left out entirely, so a logo's palette is the logo's colours, not its colours plus the black that a transparent pixel technically stores.

How do I use the palette in GIMP, Inkscape or Krita?

Download the GIMP palette (.gpl) and import it; all three read the format. For a website, "Copy as CSS" gives you ready-made custom properties.

Is my image uploaded?

No. The colours are worked out in your browser. That matters for unreleased designs and client work as much as for family photos, and the network panel will show you nothing carrying your picture leave.