How to Get a Color Palette From an Image (Step by Step)
Pull a color palette from an image in seconds: pick the right photo, choose how many colors to extract, clean up the results and turn them into a usable scheme.
Updated
To get a color palette from an image, load the image into a palette extractor, choose how many colors you want, and copy the HEX codes it returns. The extractor groups similar pixels and gives you one representative color for each group. From there, trim the list to three to five colors, assign each one a job, and check that your text colors have enough contrast.
Step 1: Pick the right image
The palette can only be as good as the source. Images that work well:
- Photos with a clear mood, such as a landscape at dusk, a styled interior, a plate of food or a film still.
- Finished artwork whose color you already admire, such as an illustration, a poster or a painting.
- Your own product or brand photography, when the site needs to sit comfortably around it.
Images that work badly are those dominated by something you do not want. A product on a large white backdrop returns mostly whites and pale grays. A portrait against a busy street returns the street. Crop first so the area you care about fills the frame. The Image Cropper does this in a few seconds.
Step 2: Extract the colors
Open the Color Palette Extractor and drop in the image. It returns the dominant colors as swatches, ordered from darkest to lightest. You can:
- Choose the number of colors: 4, 6, 8, 10 or 12. The default is 8.
- Switch the display between HEX, RGB and HSL.
- Copy a single swatch, or copy the whole list in the format you selected.
Changing the count re-runs the extraction on the same image, so it is quick to compare a tight palette of four with a wider one of twelve.
How extraction works
A photo can contain hundreds of thousands of distinct colors. Extraction reduces them to a handful using color quantization. The tool here uses the median cut method:
- Take a sample of pixels from the image, ignoring transparent ones.
- Find the channel (red, green or blue) with the widest spread of values.
- Sort the pixels by that channel and split them into two equal groups at the middle.
- Repeat the split on each group until there are as many groups as colors requested.
- Average the pixels in each group. That average is the swatch.
Two things follow from this, and they explain most surprises.
First, every swatch is an average. A sunset with bright orange and deep red may return a brick tone that appears in neither. Averages are also less saturated than the most vivid pixels they contain.
Second, groups are split by pixel count. Large areas, such as sky, walls and backgrounds, get more of the swatches. A small red umbrella in a gray street scene may not appear at all at four colors and only show up at ten or twelve.
Step 3: Decide how many colors to keep
Extract more than you need, then cut.
| Extract | What you get | Good for |
|---|---|---|
| 4 | Only the broadest color areas | A quick read of the overall mood |
| 6 to 8 | Main colors plus a few shades of each | Most web and brand work |
| 10 to 12 | Fine variations and small accents | Illustration, or finding a hidden accent color |
For the final palette, three to five working colors is a sensible target. A long-standing rule of thumb from interior design, the 60-30-10 rule, translates well to screens:
- About 60 percent dominant color: backgrounds and large surfaces. Usually a light or dark neutral from the image.
- About 30 percent secondary color: cards, headers, sections, illustrations.
- About 10 percent accent color: buttons, links, highlights. The most saturated swatch is usually the right choice.
Add one very dark and one very light tone for text and page background. The first and last swatches in the darkest-to-lightest ordering are natural candidates.
Step 4: Clean up the swatches
Raw extracted colors rarely go straight into a design. Typical fixes:
- Remove near duplicates. If two swatches are the same hue a few percent apart in lightness, keep one.
- Boost the accent. Switch the extractor to HSL and look at the middle number. If your accent has a saturation under about 50 percent, raise it by 10 to 20 points so it reads as intentional rather than muddy.
- Fix the neutrals. Extracted darks are often a murky brown or gray. Keeping the hue but lowering lightness to 10 to 15 percent gives a text color that still belongs to the image.
- Check the extremes. A palette with no dark color or no light color is hard to build a layout from.
HSL makes these edits predictable because you change one number at a time. If the notation is new to you, HEX, RGB and HSL color codes explained covers it.
Step 5: Turn the palette into a system
A handful of swatches is not yet a design system. Three steps get it there.
Expand each key color. Paste your accent HEX into the Color Palette Generator. It produces a tint and shade scale for hover states, borders and backgrounds, shows complementary, analogous, triadic and split-complementary partners in case the image lacked a good second color, and exports the result as CSS variables, a Tailwind config or a plain HEX list.
Check contrast. Colors that look fine side by side in a photo often fail as text on a background. Body text needs a contrast ratio of at least 4.5 to 1 against its background under WCAG AA, and large text needs 3 to 1. Test each text and background pair in the Contrast Checker. The reasoning behind those numbers is in WCAG color contrast explained.
Name colors by role. --color-accent and --color-surface stay valid when you later adjust a value. --color-orange does not.
Worked example
Take a photo of a beach at sunset and extract six colors. A typical result runs from a dark navy through a slate blue, a dusty purple, a coral and an orange to a pale sand.
- Background: the pale sand, lightened a little further.
- Text: the dark navy.
- Secondary: the slate blue for headers and cards.
- Accent: the coral for buttons, with saturation nudged up.
- Dropped: the dusty purple and the orange, which sit too close to the slate and coral to earn a role.
Navy text on pale sand will pass a contrast check comfortably. White text on the coral button may not, so test it and darken the coral if needed.
Try it
Drop a photo into the Color Palette Extractor, set the count to 8, and copy the HEX list. Pick your accent, then paste it into the Color Palette Generator to build the scale around it. More tools for working with color are in the colors category.