🔍

Dominant Colour Extractor

Extract the dominant colour palette from an image

POST 1 credit /v1/image/extract/colors
curl -X POST "https://image.toolkitapi.io/v1/image/extract/colors" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://toolkitapi.io/static/samples/sample-image.png", "count": 5}'
import httpx

resp = httpx.post(
    "https://image.toolkitapi.io/v1/image/extract/colors",
    json={"url": "https://toolkitapi.io/static/samples/sample-image.png", "count": 5},
)
print(resp.json())
const resp = await fetch("https://image.toolkitapi.io/v1/image/extract/colors", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"url": "https://toolkitapi.io/static/samples/sample-image.png", "count": 5}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "colors": [
    {"hex": "#e85d2c", "rgb": {"r": 232, "g": 93, "b": 44}},
    {"hex": "#1a3c5e", "rgb": {"r": 26, "g": 60, "b": 94}},
    {"hex": "#f4a623", "rgb": {"r": 244, "g": 166, "b": 35}},
    {"hex": "#8b2e14", "rgb": {"r": 139, "g": 46, "b": 20}},
    {"hex": "#d4e7f2", "rgb": {"r": 212, "g": 231, "b": 242}}
  ],
  "count": 5,
  "image_size": {"width": 1920, "height": 1080}
}

Try It Live

Live Demo

Description

Extract the dominant colour palette from an image

How to Use

1

1. Send a POST request with an `image` (base64) or `url` field, and optionally set `count` for the number of colours.

2

2. Alternatively, use the GET variant with `url` and `count` query parameters.

3

3. The response contains an array of colour objects, each with `hex` and `rgb` representations.

4

4. Use the extracted palette for theme generation, accessibility contrast checks, or visual categorisation.

About This Tool

Use the Dominant Colour Extractor to analyse an image and extract its most prominent colours as hex codes and RGB values. It uses the ColorThief algorithm with a quantization fallback for robust palette extraction.

This is perfect for design tools, branding automation, and any workflow where you need to derive a colour scheme from an image. Request between 1 and 20 colours per extraction.

Both POST (base64 or URL in JSON body) and GET (URL as query parameter) variants are available, making it easy to integrate from server-side code or browser-based workflows.

Why Use This Tool

Frequently Asked Questions

How are dominant colours determined?
The endpoint uses the ColorThief algorithm, which applies modified median cut quantization to identify the most visually prominent colours. A PIL quantize fallback is used if ColorThief encounters issues.
Can I extract colours from transparent images?
Yes. The image is converted to RGB before analysis, so transparent areas are treated as their underlying colour values.
What is the maximum number of colours I can extract?
You can request up to 20 dominant colours per image by setting the `count` parameter.

Start using Dominant Colour Extractor now

Get your free API key and make your first request in under a minute.