Dominant Colour Extractor
Extract the dominant colour palette from an image
/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
{
"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
Description
How to Use
1. Send a POST request with an `image` (base64) or `url` field, and optionally set `count` for the number of colours.
2. Alternatively, use the GET variant with `url` and `count` query parameters.
3. The response contains an array of colour objects, each with `hex` and `rgb` representations.
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
- Brand colour extraction — Derive a colour palette from a logo or product image
- Dynamic theming — Automatically style a page based on a hero image's dominant colours
- Content categorisation — Tag images by colour profile for visual search
- Accessibility checks — Extract foreground/background colours to verify contrast ratios
- Design inspiration — Generate colour palettes from photography or artwork
Frequently Asked Questions
How are dominant colours determined?
Can I extract colours from transparent images?
What is the maximum number of colours I can extract?
Start using Dominant Colour Extractor now
Get your free API key and make your first request in under a minute.