Color palette generator from image
Pick a photo or image to get its 3 to 10 main colours, each with HEX, RGB and its share of the image. The image is read in your browser and never uploaded.
How do you get a colour palette from an image?
Tap "Image file", choose a JPG, PNG, WebP or GIF, and pick the number of colours. The main colours appear at once with their HEX codes, shares and copy buttons.
- Choose the image. A photo from your camera roll, a screenshot of a post you like, a product photo or your logo.
- Choose the number of colours. 5 is the default. Fewer colours give the broad mood; more colours bring out small accents such as a red scarf in a grey street.
- Read the list. Colours are sorted by share of the image, largest first, with HEX, RGB and HSL.
- Copy. Copy one HEX code, the whole list (each HEX code with its share, one per line), or CSS variables (
--image-1,--image-2, …).
The tool shows the image size, the size it was read at, and how many pixels it counted, so you can see what went into the result.
How does the tool find the main colours?
It uses k-means: start with k colours, give every pixel to the nearest one, move each colour to the average of its pixels, and repeat until nothing changes, or after 40 rounds. Share = the colour's pixels ÷ all pixels counted.
- Scaled down first. The image is drawn at most 200 pixels on its longest side. That keeps the count fast on a phone and changes the shares very little.
- Transparent pixels skipped. Only fully transparent pixels are left out; half-transparent ones count with their colour.
- Distance in RGB. "Nearest" means the smallest straight-line distance between the red, green and blue values.
- Fixed starting point. The first colours are picked by k-means++ with a fixed seed, so the same image gives the same palette every time.
- Few colours, exact result. An image with fewer distinct colours than you asked for (a flat logo, for example) gives each of its colours once, at its exact share.
HSL is shown next to HEX and RGB because it describes the colour by hue, saturation and lightness [1], which helps when you want a lighter or less saturated version.
What does a worked example look like?
A 200 × 100 pixel image that is half sky blue, a quarter sand and a quarter sea green gives three colours: one covering half of the image and two covering a quarter each. Ask for 5 colours and you still get 3, because it has only 3.
| Area of the image | Pixels | Share |
|---|---|---|
| sky blue (#87ceeb) | 10000 | 10000 ÷ 20000 = 0.5, a half |
| sand (#e8d3a2) | 5000 | 5000 ÷ 20000 = 0.25, a quarter |
| sea green (#2e8b57) | 5000 | 5000 ÷ 20000 = 0.25, a quarter |
A real beach photo has thousands of shades of each. With 3 colours the tool returns one average blue, one sand and one green, close to these; with 8 it splits them into lighter and darker blues, wet and dry sand, and so on. Shares are rounded to one decimal, so their sum can be a little over or under the whole.
How do you use the palette for posts and a brand?
Take the largest colour as a background, a dark one for text, and a small bright one as an accent. Then check text contrast and build matching harmonies with the colour palette generator.
- Background: the colour with the largest share, or a tint of it, keeps the photo's mood.
- Text: a dark colour from the list, or a dark shade of the main one.
- Accent: a small, bright colour for buttons, prices and highlights.
- Check and extend: paste a HEX code into the colour palette generator to see its contrast on white and black, its tints and shades, and its complementary colours.
Reusing the same codes in every template keeps your feed and your store recognisable. The Instagram quote maker takes your HEX codes directly.
Do it in Shatla.io
Shatla.io is one way to sell palettes or presets made from your photos as a digital download from your store [2]. It sells digital products only [2].
Photographers and designers often sell the look of their photos: a palette pack, a set of presets or matching templates. Shatla.io lets you sell digital products from your store [2]. It sells digital files only: it does not print, stock or deliver anything [2]. For what each plan includes, see the price in your country. The digital product guide shows each step.
The screenshots come from the Shatla.io screenshot library: a placeholder store shown in the real app, with example names and numbers, not a customer (how we check).
Add the palette or preset file as a digital product in your store.

Shatla.io 5968ccf73d67, Add the product to your store page and share the store link in your bio.
See how Shatla.io's digital product sales work.
Frequently asked questions
How do I get the colors from a photo?
Pick the photo in the tool above and choose how many colours you want. It lists the main colours with HEX, RGB and their share of the photo. Copy one code or the whole list.
Is my photo uploaded?
No. The browser draws the photo on a canvas on your own device and counts the colours there. Nothing is sent to a server, and the photo is gone when you close the page.
Why does the palette show fewer colours than I chose?
The image has fewer distinct colours than that, such as a flat logo. The tool then lists each of its colours once with its exact share, instead of inventing in-between colours.
Can I get the colour of one exact spot?
This tool finds the main colours of the whole image. For one spot, crop the image to that area first, then pick 3 colours: the largest share is the colour of that spot.
Sources
- CSS Color Module Level 4, W3C. Accessed .
- Shatla.io features list (features.json), Shatla.io. Accessed .