← ImgScalePIXELLAB
Deep Dive · Color

How to Extract a Color Palette from Any Image

By ImgScale Team  ·  June 2026  ·  7 min read · by kizura

Every great design starts with a palette. And the best palettes often don't come from a color wheel — they come from images: a sunset photo, a retro movie poster, a favorite piece of fabric. Extracting those colors precisely is harder than it sounds, because the "dominant" colors in an image aren't always the most visually prominent ones.

This guide explains how palette extraction actually works, why some tools give better results than others, and how to put a PixelLab-extracted palette to use in your workflow.

Open the Palette Extractor
In this guide
  1. How palette extraction works
  2. Median-cut vs k-means
  3. Choosing the right number of colors
  4. Understanding the sort modes
  5. Using your palette in CSS
  6. Using your palette in Tailwind
  7. Using your palette in Figma
  8. Tips for better palettes

How palette extraction works

When you drop an image into the Palette Extractor, here's what happens under the hood:

  1. The image is downscaled to 220 px on its longest edge. This speeds up processing without meaningfully changing the color distribution.
  2. Every opaque pixel is sampled and fed into a median-cut quantization algorithm that finds N representative colors.
  3. After the palette is built, every pixel in the image is re-assigned to its nearest palette color using a perceptual distance formula (redmean weighting). This produces the percentage figure you see under each swatch — the actual pixel-count share of each color.

The percentage bars are real measurements, not estimates. If a color shows 34%, exactly 34% of the image's opaque pixels were closer to that color than any other in the palette.

Median-cut vs k-means

Most people have heard of k-means clustering. It's used everywhere. But for dominant color extraction, median-cut is usually better. Here's why:

K-means

Median-cut

Practical result: Median-cut is better at finding colors that actually look like what's in the image. K-means is better at minimizing perceptual error across the whole image. For mood boards and design work, median-cut wins.

Choosing the right number of colors

The color count slider goes from 3 to 16. Here's a rough guide:

Understanding the sort modes

Once extracted, colors can be sorted three ways:

Dominance

Sorted by pixel count, highest first. This is usually what you want for design work — the most important color (the one that covers the most image area) comes first.

Hue

Sorted by hue angle (0°–360° around the color wheel, starting at red). Useful when you want to see the palette as a rainbow progression, or when you're checking for complementary relationships.

Lightness

Sorted from lightest to darkest by luminance. Useful for checking contrast ratios and building a tonal scale.

Using your palette in CSS

Select the CSS export format to get a :root block with custom properties:

:root {
  --color-1: #1B2A6B;
  --color-2: #9A5FB0;
  --color-3: #F4A259;
  --color-4: #2C6E49;
  --color-5: #FFD98A;
  --color-6: #ECE7DF;
}

Paste this into your CSS file and reference the variables throughout your stylesheet. To build a full design system from these six colors, you typically use the darkest as your background, lightest as your text base, most saturated as your primary action color, and the remaining three as accents and neutrals.

Using your palette in Tailwind

Select the Tailwind export format to get a config-ready object:

// tailwind.config.js → theme.extend.colors
{
  'brand-100': '#ECE7DF',
  'brand-200': '#FFD98A',
  'brand-300': '#F4A259',
  'brand-400': '#9A5FB0',
  'brand-500': '#2C6E49',
  'brand-600': '#1B2A6B',
}

Paste this into the theme.extend.colors section of your tailwind.config.js. You can then use bg-brand-500, text-brand-100, etc. in your templates.

Rename the keys. Replace brand-100 through brand-600 with semantic names like sky, sand, forest — whatever matches the image you extracted from. Semantic names are easier to use consistently across a project.

Using your palette in Figma

The easiest approach is to copy individual HEX codes from the swatches (just click any swatch) and paste them as Fill colors in Figma. For a more systematic setup:

  1. Download the palette strip PNG from PixelLab.
  2. Import it into Figma as an asset.
  3. Use the eyedropper on each color in the strip to create Figma Color Styles.
  4. Name the styles consistently (Brand/Forest, Brand/Sand, etc.) so they appear organized in the Styles panel.

If you prefer the JSON export, you can also use a Figma plugin like Tokens Studio to import a JSON token file directly, mapping each color to a design token.

Tips for better palettes

Extract your palette now

Drop any image into the free Palette Extractor. Click any swatch to copy its HEX code, then export as CSS, Tailwind, SCSS, or JSON — all in your browser, nothing uploaded.

Open Palette Extractor — it's free

Related: How to Turn Any Photo into Pixel Art  ·  How to Reduce GIF File Size