Color Palette Generator from Image
NEW!

Color Palette Generator from Image

Extract colors from an image in your browser: get the dominant palette as HEX, RGB and HSL, copy CSS, Tailwind or GIMP files. Nothing is uploaded.

Photo to Art

Upload an image

Drag an image here, paste it, or click to select

JPG, PNG, WebP or GIF — everything is processed in your browser

Or try an example:

All processing happens locally in your browser. Your image never leaves your device.

Keywords

color palette from imageextract colors from imageimage color pickerget hex colors from photodominant color extractorcolor palette generatorhex color from picturecss color palette from photo

Need something else?

How to use

1

Upload, drag in or paste an image — or pick one of the built-in examples (a sunset landscape, a product shot on white, a flat illustration and a transparent logo). The photo is decoded locally and never leaves your browser.

2

Choose how many colors you want (Auto, or 3 to 16) and how the palette should be sorted: by dominance (pixel share), by hue or by lightness.

3

Leave “ignore transparent pixels” on for PNG logos and stickers so the empty background does not become a fake white or black swatch.

4

Read each swatch: HEX, RGB, HSL, the share of the image it covers, the nearest CSS named color and a black-or-white label chosen for contrast. Click any value to copy it, or click the preview to add an exact pixel color with the eyedropper.

5

Open the Export tab and copy or download the palette as CSS custom properties, SCSS variables, a Tailwind colors fragment, JSON, plain text or a GIMP .gpl file — or download a PNG palette card to share.

Features

Perceptual clustering, not pixel counting

Colors are grouped with k-means in the CIELAB color space, so two shades end up in the same swatch only when your eye would call them the same. The palette entries are the average color of each group and the share tells you how much of the picture each one really covers.

Every notation on every swatch

HEX for CSS and design tools, RGB for canvas and code, HSL for tweaking lightness or saturation, plus the closest CSS named color and a WCAG-safe label. One click copies any single value; “Copy all” copies the whole export.

Exports that paste straight into your project

CSS custom properties, SCSS variables, a Tailwind theme.extend.colors fragment, JSON, plain text and a GIMP .gpl palette that GIMP, Inkscape, Krita and Aseprite open directly. Plus a PNG palette card at 800, 1200, 1600 or 2400 px for mood boards and social posts.

Eyedropper for the colors the average misses

Cluster means are great for a scheme but can smooth over a tiny accent — a logo dot, an eye, a neon sign. Click the preview and that exact pixel is added as a manual swatch alongside the extracted ones.

Transparent-aware and deterministic

Transparent pixels are excluded before clustering, so a logo on a transparent background gets a palette of the logo, not of the padding. The clustering uses a fixed seed: the same image with the same settings always produces the same palette.

Why Choose This Tool?

100% private — the image never leaves your device

The photo is decoded, downsampled and clustered by your own browser using standard web technologies. Nothing is uploaded to a server, a third-party API or a cloud store, which matters when the image is a client's unreleased product shot, a brand asset under embargo, or simply a personal photo. Because there is no round trip, the tool also keeps working offline once the page has loaded.

Colors that match perception, not just histograms

Many online extractors count pixels in a coarse RGB grid, so a photo of a red mug on a beige table returns four almost-identical beiges and no red. This tool clusters in CIELAB, where distance approximates perceived difference, so visually distinct colors are kept apart and near-duplicates are merged. You get a scheme you would actually pick by eye — and the eyedropper for anything the average smooths over.

Ready for code and design tools alike

Front-end developers get CSS variables, SCSS and a Tailwind fragment they can paste as-is; designers get HEX values to drop into Figma or Sketch, and illustrators get a .gpl file for GIMP, Inkscape, Krita or Aseprite. There is no sign-up, no watermark on the palette card and no limit on how many images you analyse.

Same engine as our art and craft generators

The palette you see here is produced by exactly the same quantizer that drives our pixel-art, paint-by-numbers, cross-stitch and coloring-page tools. Extract a palette, refine it, and you know precisely which colors those tools will use on the same photo — a consistent bridge from photograph to pattern.

How Palette Extraction Really Works: k-means in CIELAB, Why Counting Pixels Lies, and How Many Colors to Ask For

What “extract colors from an image” actually means

A photograph rarely contains five colors; it contains hundreds of thousands of slightly different ones. A palette generator is therefore not finding colors that are literally there — it is summarising a huge cloud of pixels into a few representative ones. This tool does that with k-means clustering in the CIELAB color space, and knowing what that means helps you read the result and pick good settings.

Step by step: what happens after you drop a photo

  • Decode and downsample. The browser decodes the image and scales it to at most 512 px on its long side — a thumbnail has the same colors as the full photo, and this keeps the analysis fast on a phone.
  • Drop transparent pixels. With “ignore transparent pixels” on (the default), pixels with alpha below half are removed first, so a logo on a transparent PNG is analysed as a logo rather than as a logo plus a phantom black or white swatch of padding.
  • Convert to CIELAB. Each remaining pixel goes from sRGB to CIELAB, a space designed so that straight-line distance roughly matches how different two colors look. A dark red and a dark green can be numerically close in RGB; in Lab they are far apart, which is what clustering should “feel”.
  • Seed and iterate. The cluster centres are placed with k-means++ seeding — each new centre is picked with probability proportional to its squared distance from the ones already chosen, so the seeds spread across the colors present instead of huddling in the largest region. Lloyd iterations then assign every pixel to its nearest centre and move each centre to the mean of its pixels until they stop moving.
  • Read out the palette. Each final centre is one swatch — the average of the pixels assigned to it — and the share under it is the fraction of counted pixels in that cluster.

The random choices come from a seeded pseudo-random generator, so the process is deterministic: the same image and settings always give the same palette.

Why counting pixels lies about “dominant colors”

The naive approach to dominance is a histogram: chop RGB into a coarse grid, count pixels per cell, report the fullest cells. It is fast, but it answers the wrong question. A large flat background — a wall, a sky, a backdrop — spreads across several neighbouring cells and can claim three or four of your five slots with near-identical shades, while a small, vivid subject (a red mug, a yellow raincoat) never fills one cell enough to appear. Median-cut and octree quantizers, the classic GIF-era methods, share a milder form of the same bias because they split boxes by pixel count in RGB.

k-means in Lab is not immune to area — a photo that is 70% grey wall still gives a grey-heavy palette — but it merges the near-identical shades into one centre and frees the remaining slots for perceptually distinct colors. That is why the “Product shot on white” example returns the product's colors with a single white, and why the share column is worth reading: a color at 2% may still be the accent your scheme should hinge on. If the accent is smaller still, use the eyedropper — clicking the preview adds that exact pixel as a manual swatch, no averaging involved.

Choosing the number of colors — and what “Auto” does

There is no mathematically correct palette size, only the size that suits the job. On Auto, the tool runs a quick k-means fit for several candidate counts between 2 and 12, records how tightly the pixels sit around their centres (the within-cluster sum of squares) for each, and picks the count at the knee of that curve — the point after which another color stops buying much fidelity. It is a heuristic, not an oracle: it tends to suggest few colors for flat graphics and more for photographs, and you can override it with one click.

GoalSuggested countSort by
Brand or UI scheme from a hero photo4–6Dominance
Mood board / presentation6–8Hue
Reduced palette for pixel art or a craft chart10–16Lightness
Checking what a logo really usesAutoDominance

HEX, RGB, HSL and Lab: which one do you need?

Each notation is useful somewhere different. HEX is the lingua franca of CSS, Figma, Sketch and design systems. RGB is what canvas, WebGL and most APIs want. HSL is for editing: a lighter tint or a muted hover state is one change to L or S while the hue stays put, whereas in RGB all three channels move. Lab is where the clustering ran and the space to use when reasoning about how different two colors look — the nearest CSS named color is simply the smallest straight-line (ΔE) distance in Lab. Sorting by hue walks the color wheel (greys are pushed to the end so it stays readable); sorting by lightness uses the Lab L value, light to dark.

Transparency and PNGs

Transparent regions have no meaningful color, and how a tool treats them changes the palette. Here they are excluded before clustering when the toggle is on, and shares are computed over opaque pixels only. Turn the toggle off if the transparency is itself meaningful — a sticker whose semi-transparent shadow you want represented — and note that a fully transparent image yields an empty palette rather than an invented one.

Using the palette in CSS, Tailwind, Figma and GIMP

  • CSS / SCSS: the export writes --palette-1: #…; custom properties inside :root (or $palette-1 SCSS variables), each with the nearest name and share as a comment, so the file documents itself.
  • Tailwind: the fragment is a theme.extend.colors object with 100/200/300… keys, ready to paste into tailwind.config.js; in Tailwind v4 the same values become --color-palette-100 lines in an @theme block.
  • Figma, Sketch, Canva: copy HEX values one by one, or copy the plain-text export and paste it into a styles document.
  • GIMP, Inkscape, Krita, Aseprite: download the .gpl file. It is GIMP's plain-text palette format (a GIMP Palette header, a name, then one R G B name row per color) and those programs import it directly into their palette dialogs.

Accessibility: reading the contrast hints

The label on each swatch is black or white — whichever gives the higher WCAG 2.1 contrast ratio against that color, from the standard relative-luminance formula. It is a small built-in check, not a full audit: WCAG asks for 4.5:1 for normal text and 3:1 for large text and UI components, and the label only tells you which of the two would fail later. Use it to sort your extracted colors into “can carry text” and “background only”.

When NOT to use this tool

k-means gives you representative averages. If you need the exact brand HEX from a flat logo, use the eyedropper or set the count to the number of flat colors; a photograph of a printed logo will never return the specification value because lighting and JPEG compression have already changed it. Smooth gradients are summarised into a few bands — right for a scheme, wrong if you wanted the gradient itself. And this is not a color-blindness simulator or a full contrast checker.

Working with the rest of the photo-art tools

The palette engine here is the one behind our pixel art generator, paint-by-numbers generator and coloring page generator. Extract a palette first to see how many distinct colors a photo genuinely holds, then run the same image through the pattern tool with a matching count.

Frequently Asked Questions

Is my image uploaded to a server?

No. The image is decoded, downsampled to 512 px and clustered entirely inside your browser with standard web technologies. Nothing is transmitted, and the tool keeps working offline once the page has loaded.

How does the tool decide which colors are in the palette?

Opaque pixels are converted to CIELAB and grouped with k-means clustering (k-means++ seeding, then Lloyd iterations). Each swatch is the mean color of one group and its share is the fraction of pixels assigned to that group, so the palette reflects perceived color differences rather than raw pixel counts.

Why are the colors different from what Photoshop or another site gives me?

Different tools use different quantizers — histogram bins, median-cut, octree, or k-means in RGB rather than Lab — and different pixel sampling, so their averages differ. None is “the” answer: a palette is a summary of a continuous image. If you need one exact pixel value, use the eyedropper on the preview instead of the extracted swatch.

How are transparent PNGs handled?

With “ignore transparent pixels” on (default), pixels with alpha below 50% are removed before clustering and shares are computed over the opaque pixels only, so a transparent background never becomes a fake white or black swatch. Turn it off if you want every pixel counted.

How many colors should I choose, and what does Auto do?

Use 4–6 for a UI or brand scheme, 6–8 for a mood board and 10–16 for illustration or pixel-art palettes. Auto fits several candidate counts between 2 and 12, measures how tightly pixels sit around their centres and picks the knee of that curve — a sensible default you can override.

What is the difference between HEX, RGB and HSL?

They describe the same color. HEX is the compact form CSS and design tools use, RGB is what canvas and most code APIs want, and HSL separates hue from saturation and lightness, which makes it the easiest to edit when you need a lighter tint or a muted variant.

Can I use the palette in Tailwind CSS?

Yes. The Tailwind export is a theme.extend.colors fragment with 100/200/300… keys that pastes into tailwind.config.js; for Tailwind v4 copy the HEX values into --color-* variables in an @theme block.

What is the .gpl file for?

It is GIMP's plain-text palette format. Import it in GIMP's Palettes dialog and it also loads in Inkscape, Krita and Aseprite, so you can paint or pixel with exactly the extracted colors.

What do the black or white labels mean?

The label color is whichever of black or white has the higher WCAG 2.1 contrast ratio against that swatch, using the standard relative-luminance formula. It is a quick hint about which colors can carry text; it is not a full accessibility audit.

Will the same image always give the same palette?

Yes. The k-means seeding uses a fixed pseudo-random seed, so identical image, count and settings always reproduce the identical palette — useful for versioned design assets.

Why does a gradient or a photo come out as only a few flat colors?

Because that is what a palette is: a summary. A sunset gradient is clustered into a few bands, and a photograph's texture is averaged into representative tones. Increase the count for finer steps, or use the eyedropper for a specific spot.

Why does the nearest CSS name look slightly off?

The 141 distinct CSS Color Level 4 named colors are sparse, so the tool reports the closest one by CIELAB distance together with how far away it is. It is a memorable label, not an exact match — the HEX value is the exact color.

Related Articles

Learn more