⭐ Star Palette Extractor
Pull a real color palette out of any image, KMeans doing the heavy lifting
- image
- palette
- palette_image
- Colors
- color1
- color2
- color3
- color4
- color5
- color6
- color7
- color8
- color9
- color10
Every design workflow eventually needs "give me the five main colors in this image" - for a palette that drives a prompt, a color-consistent LoRA set, a brand kit, or just to match a generation to a reference. Star Palette Extractor does exactly that: it clusters the image into its dominant colors and hands you the palette as hex/RGB/CMYK strings and as a preview image made of color tiles. The node lives under the pack's ⭐StarNodes/Color category, which tells you the design intent - this is about color work, not just debugging.
The mechanism is honest machine learning: it resizes the image down, then runs KMeans clustering (via scikit-learn) to find the N most representative colors. That's the right tool for the job - it doesn't pick the most common pixels, it finds the N centers the image's color space actually clusters around, which is what you want for a usable palette rather than ten near-identical browns.
Inputs and outputs
- image - your input.
- num_colors - palette size, 2 to 32 (default 8).
- tile_size - size of the swatches in the preview image, 32–512 (default 128).
- color_format -
All(default),Hex,RGBorCMYKfor the string outputs.
Outputs: palette (a formatted multi-color string), palette_image (the tile preview, IMAGE), Colors (another string summary), and color1 through color10 as individual strings. Feed palette straight into a prompt, or wire individual colorN values into a text/conditioning pipeline. Note the individual color outputs cap at 10 even if you ask for 32.
Install
Ships in the Starnodes2024/ComfyUI_StarNodes pack - and this one has real dependencies to call out. From requirements.txt:
cd ComfyUI/custom_nodes
git clone https://github.com/Starnodes2024/ComfyUI_StarNodes
cd ComfyUI_StarNodes
pip install -r requirements.txt
It needs scikit-learn (for KMeans) and webcolors (for the hex names). If either is missing, the pack skips the node and the console tells you exactly what to install. A bare pip install scikit-learn webcolors fixes it.
Where people get burned
The obvious one is dependency: install the pack and skip the requirements step, and this node silently won't exist in your menu. Second, palette quality tracks num_colors expectations - 8 colors on a busy photo gives you a muddy average, not art direction; crank it and pick the colors you want. And the clustering runs on a downscaled copy, so two nearly-identical source images can resolve to slightly different palettes - fine for creative use, annoying if you expected pixel-exact reproducibility.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| num_colors | INT | 82–32 | — |
| tile_size | INT | 12832–512 | — |
| color_format | COMBO | All | 4 options: All, Hex, RGB, CMYK |
Outputs (13)
| Name | Type | Description |
|---|---|---|
| palette | STRING | — |
| palette_image | IMAGE | — |
| Colors | STRING | — |
| color1 | STRING | — |
| color2 | STRING | — |
| color3 | STRING | — |
| color4 | STRING | — |
| color5 | STRING | — |
| color6 | STRING | — |
| color7 | STRING | — |
| color8 | STRING | — |
| color9 | STRING | — |
| color10 | STRING | — |