Colour palette from image
image_paletteExtract an image's main colors with their percentage share, returning hex/RGB values as CSS variables or JSON and optionally saving a swatch PNG.
Instructions
Extract the main colours of an image with their share of the picture: k-means (default, deterministic) or median cut, 1-16 colours, sorted by share. Transparent pixels are ignored. Returns hex + rgb + % per colour, CSS custom properties (:root { --color-1 … }) or JSON, and optionally writes the website's swatch strip as palette.png. Same algorithm and sampling as the website, so the colours match. Web version: https://s3eidat.github.io/palette-from-image/
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Number of colours. Default 6. | |
| image | Yes | The image: a local file path (absolute, or relative to the server's --root) or base64 data (raw or a data: URI). | |
| format | No | Export text format. Default css. | css |
| method | No | kmeans (default) or median (median cut). | kmeans |
| output | No | Where to write palette.png (file path or folder ending in "/"). Implies swatchPng. | |
| swatchPng | No | Also write palette.png (160×200 swatch per colour with its hex code). |