GameParticles
Colors

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:

  1. Take a sample of pixels from the image, ignoring transparent ones.
  2. Find the channel (red, green or blue) with the widest spread of values.
  3. Sort the pixels by that channel and split them into two equal groups at the middle.
  4. Repeat the split on each group until there are as many groups as colors requested.
  5. 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.

ExtractWhat you getGood for
4Only the broadest color areasA quick read of the overall mood
6 to 8Main colors plus a few shades of eachMost web and brand work
10 to 12Fine variations and small accentsIllustration, 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.

Tools in this guide

Frequently asked questions

How do I extract a color palette from a photo?

Load the photo into a palette extractor, choose how many colors you want, and copy the resulting HEX codes. The tool groups similar pixels together and returns one representative color per group, so you get the main colors without sampling by hand.

How many colors should a color palette have?

Three to five working colors is enough for most designs: one dominant, one or two supporting and one accent, plus neutrals for text and backgrounds. Extract six to eight from the image, then cut the list down.

Why do the extracted colors look duller than the photo?

Each extracted color is an average of many similar pixels, and averaging pulls bright highlights and deep shadows toward the middle. Small vivid details can also be absorbed into a larger group. Extract more colors, or raise the saturation slightly afterwards.

How do I find the HEX code of a color in an image?

Load the image into a palette extractor and set the display format to HEX. Each dominant color appears as a swatch with its code, ready to copy. For one exact pixel, use the eyedropper in an image editor instead.

More colors guides

JSON Formatter
Developer · Format, validate and minify JSON with syntax highlighting.
↵
Base64 Encode / Decode
Developer · Encode text to Base64 or decode Base64 back to plain text.
↵
URL Encoder / Decoder
Developer · Encode or decode URL components and query strings.
↵
Hash Generator
Developer · Generate MD5, SHA-1, SHA-256 and SHA-512 hashes.
↵
UUID Generator
Developer · Generate UUIDs v4 (random) in bulk with one click.
↵
Regex Tester
Developer · Test regular expressions against text with live match highlighting.
↵
Word Counter
Text · Count words, characters, sentences, paragraphs and reading time.
↵
Case Converter
Text · Convert text between UPPER, lower, Title, camelCase, snake_case and more.
↵
List Sorter
Text · Sort, reverse, deduplicate and shuffle lists of text.
↵
Markdown Preview
Text · Write Markdown and see a live rendered preview side by side.
↵
Percentage Calculator
Numbers · Calculate percentages, increases, decreases and what % one number is of another.
↵
Color Converter
Colors · Convert colors between HEX, RGB, HSL and HSV instantly.
↵
Snake
Arcade · Eat food, grow longer, don't hit the walls. A timeless classic.
↵
2048
Puzzle · Slide tiles and combine them to reach the legendary 2048 tile.
↵
Word Grid
Puzzle · Guess the hidden five letter word in six tries using color clues.
↵
Sudoku
Puzzle · Fill the 9x9 grid with logic. Four difficulties from easy to expert.
↵
Minesweeper
Strategy · Use number clues to clear the minefield. Classic logic, three levels.
↵
Breakout
Arcade · Smash every brick with paddle and ball. Power-ups, combos, endless levels.
↵
Typing Practice
Casual · Build your WPM and accuracy with timed drills from 30 seconds to 5 minutes. Find your weak keys.
↵
TypeRunner
Arcade · Multiplayer typing race. Race friends by link, beat computer runners, or chase your own ghost.
↵
Typing Blocks
Arcade · Type each word before its wooden block lands. Miss, and the pile climbs toward the line.
↵
Bubble Shooter
Arcade · Aim, bank shots off the walls, and pop groups of three or more bubbles.
↵
Road Rush
Arcade · Race seven rivals through traffic and punch your way to the front.
↵