Dominant colour palette of an image (hex, RGB, share)

Extracts the dominant colours of an image as hex and RGB, with each colour's share of the image.

Request

POSThttps://image-tools.p.apihiver.com/v1/colors

Upload the image in the file field (max 25 MB). Instead of a file you can send JSON: {"url": "https://…"} for a public image URL, or {"base64": "…"} — the options below then go in the same JSON object.

*
No file chosen
File. The image file (JPG, PNG, WebP, GIF, BMP or TIFF).
Integer. Number of colours, 2–12.

Parameters and body structure are inherited from this endpoint's definition. Changes here only apply to this test run.

Language
Client
1curl --request POST \
2  --url https://image-tools.p.apihiver.com/v1/colors \
3  --header 'Accept: application/json' \
4  --header 'X-API-Key: YOUR_API_KEY' \
5  --header 'content-type: multipart/form-data' \
6  --form file=@file.bin \
7  --form count=6

Dominant colour palette of an image (hex, RGB, share): Image Tools API reference

Extracts the dominant colours of an image as hex and RGB, with each colour's share of the image. This endpoint is part of the Image Tools API: Resize, crop, convert, rotate and compress images, add text watermarks, extract colour palettes and make placeholder images.

Example response (200, application/json)

Success.

1{
2  "palette": [
3    {
4      "hex": "#ffffff",
5      "rgb": [
6        255,
7        255,
8        255
9      ],
10      "share": 0.8958
11    },
12    {
13      "hex": "#606060",
14      "rgb": [
15        96,
16        96,
17        96
18      ],
19      "share": 0.0272
20    },
21    {
22      "hex": "#c4c4c4",
23      "rgb": [
24        196,
25        196,
26        196
27      ],
28      "share": 0.0263
29    }
30  ],
31  "dominant": "#ffffff"
32}

Errors

  • 400 — A required parameter is missing or a value has the wrong format.
    1{
    2  "error": {
    3    "code": "INVALID_INPUT",
    4    "message": "Provide a file upload, 'url', or 'base64'."
    5  }
    6}

Gateway errors (missing key, no subscription, rate limits) are listed in Error codes.