Color Palette from Image
A color palette from image is the short list of colors that actually appears in a picture, with the hex, RGB, and HSL values ready to paste into a stylesheet. This tool extracts them in your browser and shows the contrast of each one against white and black.
What dominant color extraction actually does
A photo usually contains thousands of different colors. Even a simple flat illustration has a few hundred once anti-aliasing mixes the edges. Nobody wants to pick 40 000 by hand, so the image has to be reduced to a fixed number of representative colors, a process called quantization.
Median cut works like this: start with one box holding every pixel, then repeatedly split the box with the widest color range in half along its longest channel until you have as many boxes as you want colors. The average of each box becomes one palette entry. It is fast and never produces a color not in the picture.
K-means works on clusters instead. You choose a number of cluster centres, assign every pixel to the nearest centre, then move each centre to the average of the pixels assigned to it. Repeat that and the centres settle on the dominant colors. It usually finds a better spread than median cut, for a little more computation.
This tool uses k-means. The image is first drawn onto a small canvas, capped at 220 pixels on the long side, so a large photo does not have to be analyzed pixel by pixel. The first centre starts at the average color of the image, and the others grow towards the pixels furthest from the colors already chosen. The starting points are deterministic, so the same image always gives the same palette.
How to use the palette extractor
Upload an image. PNG, JPG, WebP, GIF, and SVG work. The file is decoded by the browser and drawn on a canvas inside the tab, so an unpublished product shot or a private screenshot is fine to use here.
Set how many colors you want. The slider goes from five to ten. Five is usually enough to describe a photo, and ten is about the limit before the clusters describe individual objects instead of the overall look.
The swatches come back sorted by how much of the picture each color covers. If the top swatch covers 60 percent of the frame, it is probably the background of the photo and a sensible default for a page background.
The eyedropper picks a single exact pixel. Click anywhere on the preview to read the color under the pointer, and the same value appears underneath. With the preview focused, the arrow keys move the sample point and Enter samples it, so the tool works without a mouse.
Every swatch gives you the hex value, the RGB triplet, the HSL triple, and the contrast ratio against both white and black. The hex value is what you paste into CSS, the RGB triplet is what a design tool expects, and HSL is the one to use when you want to build a scale, because you can change the lightness without touching the hue.
Reading the contrast numbers
The two ratios under each swatch tell you how legible text will be on that color. The number is a ratio between 1 and 21. A ratio of 1 means the colors are identical, and 21 is black text on white, the largest gap the formula can produce.
WCAG 2.1 asks for a contrast ratio of at least 4.5 to 1 for normal body text and 3 to 1 for large text, which means 18 point regular or 14 point bold and above. AAA raises that to 7 to 1. Non-text elements such as button borders need 3 to 1.
The tool uses the same relative luminance formula the guidelines use, so the numbers match what a contrast checker reports for the same pair of colors.
Each swatch also says which of black or white text reads better on it, and whether that pairing reaches AA or AAA. That is often the fastest way to build a palette that works: pick the color for a large surface, then check the swatch you will put text on.
The ratio tells you about that one pair of colors. A color that passes against white can still fail against a dark gray next to it, so check the pairing you plan to ship.
Exporting the palette
The export panel writes the palette in three formats. The CSS tab gives you custom properties on a root selector, the easiest way to keep a palette in one place and let the rest of the stylesheet refer to the colors by name.
The Tailwind tab gives you a snippet for tailwind.config.js with one entry per color under a palette key, so you get classes such as bg-palette-1. Tailwind 4 no longer reads a JavaScript config file for most projects, so the same values are shown as a @theme block in CSS. Use whichever matches your project.
The JSON tab gives you the full record for each color: hex, RGB, HSL, the two contrast ratios, and the share of the image it covers. That suits design tokens that feed a style dictionary, or a handoff to someone working in a different tool. Every format has a copy button. If you need a single color as a decimal value for a Discord embed stripe, the Discord embed color picker turns hex into the number the Discord API expects.
:root {
--color-1: #b85c38;
--color-2: #e6d5c3;
--color-3: #7d4a2c;
--color-4: #2f2a26;
--color-5: #8f9a6b;
}Worked example: a product photo
Here is a run with a photo of a terracotta pot on a wooden table, 1600 by 1200 pixels, with the tool asked for six colors.
The top swatch is the clay of the pot and covers a bit over a third of the frame. The second is the bleached wood of the table. The third is the shadowed underside of the pot, the same hue as the clay but much darker. The remaining three come from the leaves behind the pot and the highlight on the rim.
That third swatch is worth a second look. It reads as a different color at a glance, but it is the same hue with the lightness pulled down. You would use it as a shadow or an active state rather than a separate brand color, and the export makes that clear because the HSL values sit close in hue and differ mainly in lightness.
The contrast numbers then do the practical work. The clay swatch scores 4.54 to 1 against white, which just clears the AA threshold for body text but sits well under the 7 to 1 AAA level. The bleached wood swatch scores 1.43 to 1 against white and 14.67 to 1 against black, so any label placed on it has to be black. The tool shows both numbers for exactly that reason.
swatch 1 #b85c38 rgb(184, 92, 56) hsl(17, 53%, 47%) 34.1% of pixels swatch 2 #e6d5c3 rgb(230, 213, 195) hsl(31, 41%, 83%) 27.6% of pixels swatch 3 #7d4a2c rgb(125, 74, 44) hsl(22, 48%, 33%) 18.2% of pixels swatch 4 #2f2a26 rgb(47, 42, 38) hsl(27, 11%, 17%) 12.4% of pixels swatch 5 #8f9a6b rgb(143, 154, 107) hsl(74, 19%, 51%) 4.9% of pixels swatch 6 #d9cbb4 rgb(217, 203, 180) hsl(37, 33%, 78%) 2.8% of pixels
Edge cases and troubleshooting
Photos often show a white or black swatch you do not recognize. Anti-aliased edges and soft shadows create near-white and near-black pixels, and those pixels are part of the image, so the palette picks them up. If a stray swatch gets in the way, the eyedropper finds the color you wanted.
Transparent areas are ignored. Pixels with less than half opacity are skipped so the empty space around a cut-out logo does not turn the palette gray.
Colors are 8 bit per channel, so each channel is a whole number from 0 to 255. A photo saved with a wide gamut profile such as Display P3 may also come back with slightly different numbers than your design software shows, because the browser converts to sRGB first.
If the palette takes a moment on a large photo, that is the analysis step working through the pixels. Cropping the image down first makes it faster.
If a swatch looks wrong next to the original, compare its hex value with the eyedropper reading for the same pixel. The eyedropper reads one exact pixel, a swatch is the average of a whole cluster, so a swatch on a gradient lands between its ends.
Explore more image tools on Tolz.me.