Nodes/ComfyUI Krea Palette Tools/Krea Palette Extractor
ComfyUI Node

Krea Palette Extractor

Pull a palette out of any image

By SurrealByDesign·Created 2 months ago·Updated 2 months ago· 2
Krea Palette Extractor
  • image
  • palette_json
  • palette_preview
  • color_count
num_colors8
min_delta_e10.0
modemost_populous

The "Krea" in the name is about where the palette ends up, not how it's made. KreaPaletteExtractor never calls Krea's API, needs no key, and does nothing but color math on your machine. Feed it any image - a mood board, a product photo, a concept-art frame - and it hands back the colors that actually define it, ranked the way you want them.

Why bother? Krea 2 has no palette field. You prompt it with words or a style reference, and the open-weights version is pure natural language: long, specific sentences beat short ones. So getting from "this reference image" to "vivid red, sage green, warm tan" has been a screenshot-and-eyeball chore. This node is the un-chore. It's also the front half of the pack's whole pipeline - both of the other nodes in Krea/Palette eat its output.

How it works

Under the hood it's pleasingly old-school:

  • The image is resized down to a small 150×150 square, then pixels are fed to k-means clustering (scikit-learn, fixed seed, so runs are deterministic).
  • The resulting cluster centers are deduplicated in LAB color space using CIE76 Delta-E, not raw RGB distance. Two colors can be numerically close in RGB and look nothing alike to the eye; Delta-E is the fix for exactly that.
  • The survivors are ranked according to your mode, and the swatch strip and hex list are built.

The inputs that matter

  • image - your reference. Any IMAGE wire works.
  • mode - the one you'll actually fiddle with. most_populous ranks by raw pixel frequency, which buries a small accent color under a big dull background. The other six - vibrant, light_vibrant, dark_vibrant, muted, light_muted, dark_muted - score toward a vibe target instead. If the background is boring, switch to vibrant before you suspect the node is broken.
  • num_colors - target palette size, 2–16, default 8. That's the k-means cluster count before dedup, so the final list can come out shorter.
  • min_delta_e - minimum perceptual distance between kept colors (0–100, default 10). Leave it alone until two swatches look like duplicates.

Outputs

  • palette_json (STRING) - the hex array, ordered per mode. This feeds KreaPaletteToPromptText.
  • palette_preview (IMAGE) - a labeled swatch strip; drop it on PreviewImage or SaveImage.
  • color_count (INT) - how many colors survived dedup. Handy for a text display, honestly forgettable otherwise.

Install

This is one of the nicer installs you'll do: no model files at all, one extra pip dependency.

cd ComfyUI/custom_nodes
git clone https://github.com/SurrealByDesign/ComfyUI-Krea-Palette-Tools

Or search "ComfyUI Krea Palette Tools" in ComfyUI Manager and let it handle the rest. The only extra dependency is scikit-learn (k-means needs it), which Manager installs from requirements.txt automatically; by hand it's pip install scikit-learn. torch, numpy, and Pillow ship with ComfyUI and are deliberately not pinned - good call, because reinstalling torch can drag in a build that doesn't match your CUDA setup. After restarting you'll find all three nodes under Krea/Palette. Python 3.10+.

Where people trip

The node fails gracefully to flat gray: a single-color or degenerate image (tiny, parse-error, one cluster after dedup) returns a #808080 swatch rather than crashing the workflow. A gray strip isn't a bug, it's the input being useless. And if you're on the free local path (you should be - the hosted style-reference feature isn't in the open weights), remember palette_json is what you actually want out of this node, not the pretty preview.

CategoryKrea/Palette

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
num_colorsINT82–16
min_delta_eFLOAT10.00–100
modeCOMBOmost_populous7 options: most_populous, vibrant, light_vibrant, dark_vibrant, muted, light_muted, +1

Outputs (3)

NameTypeDescription
palette_jsonSTRING
palette_previewIMAGE
color_countINT