Skip to content
FileKit
Color And DesignRuns in your browser6 min read

Image Palette Extractor

This image palette extractor analyses every sampled pixel in an uploaded photo and reduces them to a small set of dominant colours using median cut quantisation, the same class of algorithm used inside format converters and design tools that need to build an accurate colour palette from an arbitrary image. Drop in a photo and the extracted swatches appear with their hex codes and their share of the image, ready to copy.

Loading the tool interface
Files never leave your deviceNo upload wait and no queueNo signup, watermark or file limit

Extracting a palette from a photo is harder than it sounds because a typical image contains thousands or millions of distinct colours, most of them tiny variations of a handful of dominant tones caused by lighting, compression and natural texture. A useful extractor has to group those near duplicate colours together intelligently rather than just picking the most frequent exact pixel value, which would often return several near identical blues instead of the one blue that actually represents the image.

The image is decoded and processed entirely in your browser using the canvas API, so a private photo, an unreleased product shot or a client mockup never has to be uploaded anywhere to have its colours extracted.

Why an image palette extractor needs real quantisation

The naive approach to extracting colours is to count how often each exact pixel value appears and return the most frequent ones, but this fails badly on real photographs. A smooth blue sky might contain ten thousand extremely similar but not identical blues due to gradient banding, compression artifacts and sensor noise, so counting exact values splits what is visually one dominant colour into hundreds of nearly tied entries, none of which individually wins a simple frequency count.

Median cut solves this by working with colour ranges rather than exact matches. It recursively splits the full set of sampled pixels into buckets based on which colour channel has the widest range of values in the current bucket, dividing at the median so each split produces two roughly equal sized groups, until the target number of buckets is reached. The average colour of each final bucket becomes one palette swatch, which naturally groups all those near identical blues into one representative colour instead of splitting them apart.

How this tool finds the dominant color from image pixels

Before quantisation runs, the image is drawn onto a canvas and its pixel data is read with getImageData, then sampled at a fixed interval rather than processing every single pixel, since a typical photo has far more pixels than are needed to characterise its colour distribution accurately. Sampling every few pixels rather than every pixel keeps the extraction fast even on a large image while barely changing the resulting palette, since neighbouring pixels are almost always very similar in colour.

The sampled pixels then go through the median cut splitting process described above, and each final bucket's average colour, along with what share of the sampled pixels fell into that bucket, becomes one entry in the extracted palette, sorted from the largest share to the smallest so the truly dominant colour appears first.

What affects how well you can extract colors from photo images

Photos with a small number of large, flat colour regions, product shots on a plain background, illustrations, or logos, extract very cleanly because each visually distinct area really does correspond to one dominant colour with only minor internal variation. Busy, highly textured photographs, dense foliage, crowds, patterned fabric, extract less cleanly because the human eye still perceives a dominant colour impression even when the actual pixel data is a wide scatter with no single colour genuinely dominating by area.

Increasing the number of palette swatches you request generally improves accuracy on complex images, since more buckets means each one covers a narrower, more internally consistent range of colours, at the cost of a palette that is less immediately usable as a small, curated colour scheme.

Using the extracted palette

A palette pulled from a photograph is a strong, fast starting point for a colour scheme, particularly for projects that need to feel connected to a specific piece of photography, a hero image on a landing page, a product photo for an ecommerce listing, or a piece of artwork being turned into a brand identity. The extracted colours are real, photographed colours rather than idealised, evenly spaced theoretical ones, which often gives a resulting design more warmth and specificity than a purely generated palette.

Because the extracted swatches are ordinary hex colours, they work directly as input to a color palette generator for building complementary or analogous variations, or to a tint and shade generator for expanding one extracted colour into a full usable scale.

How this image palette extractor works under the hood

The pipeline is: decode the image with the browser's built in decoder, draw it to an off screen canvas at its natural resolution, read pixel data with getImageData, sample a bounded number of pixels at a fixed stride to keep the algorithm fast, then run median cut recursively on that sample until the requested number of buckets exists. Each bucket's average red, green and blue values become one hex swatch, and the bucket's relative sample count becomes its reported percentage.

This entire process, including decoding a multi megapixel photo, typically finishes in well under a second on ordinary hardware, because the sampling step keeps the actual amount of data the quantisation algorithm has to process manageable regardless of the original image's full resolution.

Median cut extraction at a glance
StepWhat happens
DecodeThe browser decodes the image and draws it to an off screen canvas
SamplePixels are read at a fixed interval up to a bounded sample size
SplitThe widest channel range bucket is split at its median, repeated until enough buckets exist
AverageEach bucket's mean colour becomes one palette swatch, sorted by sample share

How to extract a palette from an image

  1. 1

    Upload a photo

    Drag or drop a PNG, JPG or WebP image, or click to browse for one.

  2. 2

    Choose how many colours to extract

    Pick a palette size, more swatches for busy images, fewer for a clean, curated result.

  3. 3

    Review the extracted swatches

    Each swatch shows its hex code and what share of the sampled pixels it represents.

  4. 4

    Copy the colours you need

    Copy any individual hex value, or the whole palette, for use in your own design work.

Related tools worth bookmarking

Sources and further reading

Frequently asked questions

Common questions about the image palette extractor.

Median cut color quantization is an algorithm that repeatedly splits a set of colours into smaller groups, always dividing whichever group currently has the widest range along its most varied colour channel, at the median point so each split produces two evenly sized groups. Once the target number of groups exists, the average colour of each group becomes a palette entry, which groups visually similar colours together far more reliably than counting exact pixel matches.

Because real photographs almost never contain many pixels of one single, identical colour value. Natural lighting variation, compression artifacts and sensor noise split what looks like one dominant colour into thousands of extremely similar but not identical values, so a simple frequency count would return a scatter of near duplicates instead of one representative swatch for that colour.

Five to eight swatches suits most photographs, giving enough range to capture the main dominant colours without producing so many that the palette stops feeling curated. Very busy or highly textured images sometimes benefit from a larger palette, ten to twelve swatches, to capture more of the genuine colour variety present in the image.

Only marginally. This tool samples a bounded number of pixels at a fixed interval across the image rather than processing every pixel, and because neighbouring pixels in a photograph are almost always very similar in colour, sampling captures the same dominant colours a full pixel by pixel analysis would, just considerably faster.

Yes, and it works particularly well. When you get color palette from picture content with large, flat colour regions such as product photography or illustrations, median cut converges very cleanly since each visually distinct area really does correspond to a tight cluster of similar pixel values with little internal variation to average across.

Yes. Since this image palette extractor samples pixels rather than relying on a specific resolution, even a small or heavily compressed photo provides enough sampled pixels for median cut to produce a representative palette, though extremely tiny thumbnails with very few unique pixels can occasionally produce a less nuanced result than a full resolution original.

Very often yes, but not perfectly, since the algorithm works from pixel statistics rather than semantic understanding of what is in the photo. A small but visually striking object, a red flower in a mostly green field, might not appear in the extracted palette if it occupies too few pixels to form its own bucket, even though a human viewer would immediately name it as a defining colour.