ximg.es

Colour palette from an image

Upload an image, or pick a random photo, and get its main colours ready for your CSS. Everything is calculated in your browser.

Image the palette is extracted from
Or try a random photo of…

Format

How the palette is calculated

The image is scaled down to about 96 pixels across and its colours are grouped with k-means: the algorithm finds the N colours that best represent all the pixels. The grouping happens in OKLab space, which measures differences the way the eye perceives them; in RGB, two very different greens can look “close” and two near-identical greys far apart. The starting point isn’t random, so the same image always gives the same palette.

Average colour and dominant colours

They’re not the same thing. The dominant colours are the ones covering the most area; the average colour is the blend of all of them, as if the image were shrunk to a single pixel. The average is usually a muted tone that doesn’t appear as such in the photo, but it makes the best loading background: it resembles the image as a whole and doesn’t stand out when the photo arrives. It’s the same colour the ximg.es generator stores for every photo in its bank.

Ideas for using the palette

If you’re going to put text on any of these colours, check the contrast first with the WCAG checker.

Frequently asked questions

How do I get the colours from an image?

Upload the image or drop it here. The tool calculates its main colours and gives you them in HEX, RGB or HSL, with the share of the image each one covers.

Is my image uploaded to a server?

No. The pixels are read with canvas in your browser; the image never leaves your device.

What’s the difference between the dominant colour and the average colour?

The dominant colour covers the most area; the average is the blend of every pixel. The average works better as a background while the image loads.

Why isn’t it exactly the colour I see in the photo?

Each palette colour is the average of a group of similar pixels, so it smooths out nuances. If you need an exact pixel, use an eyedropper.

How many colours should I extract?

Five or six are enough for a website palette. With more, you start getting variations of the same tone.

Can I use the palette in Tailwind?

Yes: copy the JSON or the CSS variables and use them in theme.extend.colors or as var(--color-1).

More tools

See all tools · Placeholder image generator