All Tools

Color Extractor: Dominant Colors of an Image

Get the dominant colors of any image in your browser, 2 to 16 of them, each with hex, RGB, HSL and its share. Sort by share or hue, skip near-white or near-black, export CSS, JSON or PNG. Nothing is uploaded.

Drag an image here, paste, or choose

One image, up to 50 MB. PNG, JPEG, GIF, BMP, WebP and AVIF files. Nothing is uploaded.

Want one colour for the whole picture? Try the average color finder.


About the Color Extractor

The Color Extractor lists the dominant colors of a picture. Choose, drop or paste one image and the tool shows the main colors it contains, each with a swatch, a hex code, an rgb() value, an hsl() value, a bar and the share of the picture it covers, to one decimal place. You decide how many colors to list, how to sort them and which near-white or near-black pixels to leave out.

It reads PNG, JPEG, GIF, BMP, WebP and AVIF files up to 50 MB. Your image never leaves your device. Nothing is uploaded, there is no account, and the pixels are read and counted by your own browser.

How to use it

Steps

  1. Choose an image, drop it on the page or paste it. One image is open at a time.
  2. Set Number of colours from 2 to 16. The default is 8.
  3. Pick Sort by Share (largest first) or Hue.
  4. Turn on Ignore near-white or Ignore near-black if a plain background is crowding out the colors you care about.
  5. Press the copy button beside a color to take its hex code, or use Copy CSS, Copy JSON, Download SVG or Download PNG for the whole palette.

If the picture is fully transparent, or every pixel was filtered out, the page says "No colours found. The picture is transparent or every pixel was filtered out." Turn off the ignore options or pick another image.

How the share is worked out

Each listed color covers a group of similar pixels. Its share is that group's size as a percentage of the pixels that were counted:

share=100×pixels in the groupcounted pixels\text{share} = 100 \times \frac{\text{pixels in the group}}{\text{counted pixels}}

Pixels with an alpha value below 25 (almost fully transparent) never count, and neither do pixels removed by the ignore options. So shares are shares of what was counted, not of the whole canvas.

Take a 10 by 10 image, which has 100 pixels. Four columns are blue, three are red, two are white and one is fully transparent. The transparent column is not counted, so 100−10=90100 - 10 = 90 pixels remain:

  • Blue: 100×40/90=44.4100 \times 40 / 90 = 44.4 percent.
  • Red: 100×30/90=33.3100 \times 30 / 90 = 33.3 percent.
  • White: 100×20/90=22.2100 \times 20 / 90 = 22.2 percent.

Now turn on Ignore near-white. The 20 white pixels are left out, so 70 pixels are counted. Blue becomes 100×40/70=57.1100 \times 40 / 70 = 57.1 percent and red becomes 100×30/70=42.9100 \times 30 / 70 = 42.9 percent. The shares are rounded to one decimal place, so a list can add up to 99.9 or 100.1 percent.

How the colors are found

For speed, the image is read at up to 1,000,000 pixels, so a larger photo is scaled down first. Every counted pixel is then placed in a histogram that keeps 5 bits of each channel. A channel value vv from 0 to 255 lands in bin

bin=⌊v8⌋\text{bin} = \left\lfloor \frac{v}{8} \right\rfloor

which gives 32 levels per channel and 323=3276832^3 = 32768 bins in all. For rgb(59, 130, 246) the bins are ⌊59/8⌋=7\lfloor 59/8 \rfloor = 7, ⌊130/8⌋=16\lfloor 130/8 \rfloor = 16 and ⌊246/8⌋=30\lfloor 246/8 \rfloor = 30. Every shade within 8 levels of each other on each channel, such as red values 56 to 63, falls in the same bin, which is how JPEG noise and gentle gradients are merged.

The tool then runs median cut. It starts with one box holding all the bins. While there are fewer boxes than the number you asked for, it takes the box with the most pixels, finds the channel (red, green or blue) with the widest range of values, sorts the box's bins along that channel and cuts it at the weighted median, so each half holds about the same number of pixels. Each final box is reported as the mean color of the pixels in it, weighted by pixel count, and its share is the box's pixel count over the counted total.

How it differs from the average color

The average color blends every pixel into one value. A picture that is half pure red, rgb(255, 0, 0), and half pure blue, rgb(0, 0, 255), averages to (255+02,0,0+2552)=(127.5,0,127.5)\left(\frac{255 + 0}{2}, 0, \frac{0 + 255}{2}\right) = (127.5, 0, 127.5), which is about rgb(128, 0, 128), a purple that appears nowhere in the picture. With 2 colors, the Color Extractor reports red at 50.0 percent and blue at 50.0 percent, both colors that are really there. Use the Average Color Finder when you want one blended tone for a region, and the Color Extractor when you want the colors the picture is made of.

Choosing the options

  • Number of colours. A small count such as 3 or 4 gives broad groups, good for a theme color. A larger count such as 12 or 16 splits those groups into finer shades. Because each box is a mean, the same shade can be reported slightly differently at different counts.
  • Sort by Share puts the biggest areas first. Sort by Hue orders colors around the color wheel from red onward and puts greys last, dark to light, which suits a palette strip.
  • Ignore near-white drops pixels whose red, green and blue are all at least 240. Use it for product photos on a white background, otherwise white takes most of the share.
  • Ignore near-black drops pixels whose three channels are all at most 15. Use it for dark vignettes, letterbox bars and black borders.

Using the result

  • Copy CSS produces custom properties, --color-1 and so on, ready to paste into a stylesheet.
  • Copy JSON gives a list with the hex, rgb, hsl and share of each color.
  • Download SVG and Download PNG save a color strip. The PNG is named image-colors.png, and each segment is as wide as its share.

To read one exact pixel instead of a group, use the Image Color Picker. To build matching colors around a result, open the Color Palette Generator. To process many pictures at once, use the Bulk Color Extractor.

Limits worth knowing

The tool reports colors as numbers. It does not name them, remove backgrounds or read embedded color profiles, so values are what your browser shows in sRGB. A color is a mean of similar pixels, so it can differ by a few levels from any single pixel in the file. JPEG compression adds that kind of variation, which is another reason a PNG gives steadier results.

Frequently asked questions

Is my image uploaded anywhere?

No. Your image never leaves your device. The pixels are read and counted by your browser, nothing is uploaded, and no account is needed.

Which image formats can I use?

PNG, JPEG, GIF, BMP, WebP and AVIF, one image at a time, up to 50 MB. You can choose the file, drop it on the page or paste it. For speed, the image is read at up to 1,000,000 pixels, so a larger photo is scaled down first.

How is this different from the average color?

An average blends every pixel into one value, which can be a color that appears nowhere in the picture. Half pure red and half pure blue average to about rgb(128, 0, 128), a purple. The Color Extractor lists the groups of colors that are actually there, each with its share. For one blended tone, use the Average Color Finder.

How is the share of each color calculated?

The share is 100 times the pixels in a color's group divided by the counted pixels, shown to one decimal. Pixels with alpha below 25 and pixels removed by the ignore options are not counted. In a 10 by 10 image with 40 blue, 30 red, 20 white and 10 transparent pixels, blue is 40 of 90 counted pixels, or 44.4 percent.

When should I use Ignore near-white or Ignore near-black?

Turn on Ignore near-white for product photos on a white background, so the background does not take most of the share. Turn on Ignore near-black for dark vignettes, borders and letterbox bars. Near-white means all three channels are at least 240, and near-black means all three are at most 15. Shares are then shares of the remaining pixels.

Why do I get a slightly different color at a different count?

Median cut splits the picture into as many boxes as you ask for, and each color is the mean of the pixels in its box. A different Number of colours cuts the boxes differently, so a shade can shift by a few levels. A small count gives broad groups and a large count gives finer shades.

What can I export?

Copy CSS gives custom properties named --color-1, --color-2 and so on. Copy JSON gives the hex, rgb, hsl and share of each color. Download SVG and Download PNG save a color strip, and the PNG is named image-colors.png, with each segment as wide as its share. A copy button beside each color takes a single hex code.

Other related tools