Color Palette
Extracts the colors an image is made of: its palette, each color named, and the dominant color name.#
/lmkit/v1/image-color-paletteFinds the palette of an image - its main colors largest share first - and names each with the basic color term a person would use (black, white, gray, red, orange, yellow, green, blue, purple, pink, brown), so a library can answer 'the blue ones', a caption can say 'a red car on gray asphalt', and a design tool can pick a matching accent. No AI model is involved: the image is box-averaged to a bounded sample, converted to CIELAB and clustered by deterministic weighted k-means; clusters closer than 'merge_distance' (CIEDE2000) are one color, clusters under 'min_share' are dropped, and the image's 'dominant_color' is the name covering the largest part once shades are pooled by name. Transparent pixels of an RGBA image take no part. The same image always produces the same palette. A payload that is not a decodable image is refused with 422 and error 'invalid_image'. If processing exceeds the configured timeout, returns 202 Accepted with a job_id. Poll GET /lmkit/v1/jobs/ for status and results.
Request body
application/json ·
| Property | Type | Description |
|---|---|---|
inputrequired | string | The input image. When input_format is 'Base64EncodedFile', provide a base64-encoded image payload. When 'FileIdentifier', provide the file ID previously returned by the lmkit/v1/files/upload endpoint. |
input_format | How the input is provided. Accepted values: 'Base64EncodedFile' or 'FileIdentifier'. Defaults to 'Base64EncodedFile'. | |
page_index | object (int32) | Zero-based page of a multi-page image (a TIFF scan) to process. Default: 0. An index past the last page is refused with 400. |
max_colors | object (int32) | The most colors the palette may hold, 1 to 32. The clustering starts from this many groups; merging close shades and dropping specks can only bring the count down. Default: 6. |
min_share | object (double) | The smallest share of the image's opaque pixels (0 to 0.5) a color must cover to be listed; smaller specks are dropped and their share is not reattributed. Default: 0.02. |
merge_distance | object (double) | Two palette entries closer than this CIEDE2000 distance (0 to 40) are shades of one color and merge. Lower it to keep close shades apart, raise it for a coarser palette. Default: 12. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | OK | |
| 202 | Accepted | |
| 400 | Bad Request | |
| 422 | Unprocessable Entity | |
| 500 | application/json | Internal Server Error |
curl -X POST "$LMKIT_ONE_URL/lmkit/v1/image-color-palette" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "",
"input_format": "Base64EncodedFile",
"page_index": 0,
"max_colors": 6,
"min_share": 0.02
}'