Ideogram Palette Extractor
The Node That Kills the Hex-Code Spreadsheet
- image
- palette_json
- palette_preview
- color_count
If you've ever hand-picked a dozen hex codes for an Ideogram 4 prompt, you know the pain this node exists to remove. Ideogram 4's most powerful feature - structured JSON prompts with explicit, ordered color palettes - is also its most tedious. This is the node that looks at a reference image and hands you back the palette as a JSON array of hex strings, ready to drop straight into the prompt. No eyedropper, no spreadsheet, no squinting at two colors that look identical on screen but are technically "different."
It's the anchor of the whole SurrealByDesign pack, and it's the first node in basically every workflow the repo ships. If you only install one thing from this pack, this is it.
What it actually does
Under the hood it's classic color-quantization: the image gets downsampled, the pixels are run through k-means clustering (scikit-learn, random_state=42 so it's deterministic) to find your target number of dominant colors, and then the interesting part - near-duplicate removal uses Delta-E perceptual distance in LAB space, not raw RGB distance. That's the detail that separates this from a naive script. Two colors that are close in RGB can look wildly different to a human eye and vice versa, so the pack measures closeness the way your eye does. Raise min_delta_e and the palette gets more distinct; lower it and you keep subtle variations.
Each surviving cluster becomes a hex string, ordered by dominance (most common color first), and the node also renders you a labeled swatch strip as an image so you can actually see what you extracted without parsing JSON by hand.
The inputs that matter
image- any ComfyUI IMAGE. Feed it the output of aLoadImage.num_colors- 2 to 16, default 8. This is the k-means cluster count, not a hard guarantee of how many colors you get back (dedup can leave fewer). For Ideogram 4's global palette, 8–12 is a sane place to start.min_delta_e- 0 to 100, default 10.0. The perceptual distance two colors must be apart to both survive. Bump it up if your palette comes back full of near-identical blues.
Outputs: palette_json (the array of hex strings), palette_preview (the swatch strip IMAGE - wire it into a PreviewImage), and color_count (how many colors actually survived dedup).
Where it feeds
palette_json plugs straight into IdeogramPaletteToGlobalJSON to become a style_description fragment, or into IdeogramPaletteOverride if you want to tweak before finalizing. For the classic colorway-study trick - same seed, same prompt, palette swapped - this node is what makes the whole thing one node instead of a clipboard fight.
Installing it
Install the pack once; all fifteen nodes come with it. Easiest is ComfyUI Manager - search "Ideogram Palette and Prompt Tools". Or:
cd ComfyUI/custom_nodes
git clone https://github.com/SurrealByDesign/ComfyUI-Ideogram-Palette-and-Prompt-Tools
Then restart ComfyUI. The only extra dependency is scikit-learn; Manager installs it from requirements.txt automatically, or run pip install scikit-learn into ComfyUI's Python. Note what's not in requirements: torch, numpy, and Pillow are deliberately excluded because ComfyUI already ships them, and the author doesn't want to risk a reinstall pulling a torch build that mismatches your CUDA setup. Nodes appear under Ideogram/Palette in the menu. Tested against ComfyUI 0.24.0 on Python 3.12, with Python ≥ 3.10 required.
Gotchas
The pack is built around "fail gracefully." A degenerate reference - a single flat color, a tiny image - won't crash anything; you'll just get a boring palette, or a flat #808080 gray fallback if extraction genuinely fails. That's by design, and it means you can wire this node into batch pipelines without babysitting it. The README's tools/palette_batch.py does exactly that: one workflow, a folder of reference images, and it queues a generation per reference with the seed locked.
One real trap worth knowing: this is an Ideogram 4 tool, and Ideogram 4's weights are non-commercial under the Ideogram license. Extracting a palette from an image you don't own and feeding it to the model is a copyright question for you, not this node - but it's a factor if you're planning to sell renders. The palette JSON itself is just hex strings; use them anywhere you like.
Troubleshooting
- Palette has fewer colors than
num_colors? Expected. Dedup is doing its job. Crankmin_delta_edown if you genuinely need the near-duplicates. #808080gray came back? Extraction hit an error or a degenerate image. Check the image actually loaded and isn't a 1×1 tensor.- No "Ideogram/Palette" menu? The node didn't load - check the console for an import error, almost always scikit-learn missing or a Python < 3.10.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| num_colors | INT | 82–16 | — |
| min_delta_e | FLOAT | 10.00–100 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| palette_json | STRING | — |
| palette_preview | IMAGE | — |
| color_count | INT | — |