Nodes/ComfyUI_StarNodes/⭐ Star Palette Extractor
ComfyUI Node

⭐ Star Palette Extractor

Pull a real color palette out of any image, KMeans doing the heavy lifting

By Starnodes2024·Created 2 years ago·Updated 2 days ago· 106
⭐ Star Palette Extractor
  • image
  • palette
  • palette_image
  • Colors
  • color1
  • color2
  • color3
  • color4
  • color5
  • color6
  • color7
  • color8
  • color9
  • color10
num_colors8
tile_size128
color_formatAll

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, RGB or CMYK for 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.

Category⭐StarNodes/Color

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
num_colorsINT82–32
tile_sizeINT12832–512
color_formatCOMBOAll4 options: All, Hex, RGB, CMYK

Outputs (13)

NameTypeDescription
paletteSTRING
palette_imageIMAGE
ColorsSTRING
color1STRING
color2STRING
color3STRING
color4STRING
color5STRING
color6STRING
color7STRING
color8STRING
color9STRING
color10STRING