ComfyUI Node

Badge Color ID Map V1

Flattening a glossy badge into a paint-by-numbers map, once, and caching it

By TeutonicMepheles·Created 4 months ago·Updated 3 days ago· 0
Badge Color ID Map V1
  • master_image
  • color_id_map
  • cache_key
  • status
◄enabledfalse►
◄map_promptEdit Image 1 into a flat Color ID Map for masking only. Preserve the exact canvas, composition, geometry, topology, object positions, outlines, separator lines, text glyphs, spacing and every small detail. Treat lighting, reflections, gradients, texture and antialiasing as appearance, not as new regions. Do not merge, split, add, remove, move or redraw a region. Replace every existing closed region with one uniform opaque palette color. Use only: #000000, #FF1744, #00E5FF, #FFEA00, #76FF03, #D500F9, #FF9100, #2979FF, #1DE9B6, #AA00FF, #C6FF00, #FF3D00, #00B0FF, #64FFDA, #E040FB, #7C4DFF. Reserve #000000 for the existing background and genuine holes. Adjacent regions must use clearly different colors. Return only the map: no legend, labels, watermark, shading, texture, glow, depth or new outlines.►
◄qualityhigh►
◄seed6►
◄map_revision0►
◄modelgpt-image-2►

What this is for

Here's the problem this node solves. You want to select "the teal region" of a rendered badge. In the flat artwork it was one hex value. In the render, after the model has done its lighting, that teal is a hundred different RGB values across a gradient - and your colour picker only ever catches one of them. Eyeballing a tolerance gets you a mask with holes in it.

Badge Color ID Map V1 asks an image model to strip the appearance out: same canvas, same geometry, same every-line-and-glyph, but each closed region repainted in one flat palette colour from a fixed 16-colour set. Then the picking is trivial and exact, because "the teal region" is now literally #00B0FF everywhere. The pack's own framing is the right one - the map never replaces your edit image, it's a lookup table for where things are.

Cost warning up front: this is a paid generation. It goes through the official ComfyUI API node path and bills against your account credits. Which is why the node has a cache, and why you should think of this as a once-per-design expense.

How it works

When enabled is true it validates that the incoming image is exactly one 1024×1024 RGB image - the badge pipeline's canvas is fixed, so this is a hard requirement, not a suggestion. Then it builds a cache key from everything that affects the output: the master image digest, prompt version, the prompt text, model, size, background mode, quality, seed and map_revision.

Cache hit, and it loads the stored PNG and returns immediately with cache: hit. Cache miss, and it expands a subgraph containing a native OpenAIGPTImageNodeV2 - officially a paid API call - with your prompt, model, 1024×1024 opaque output and quality setting, and the result is what gets cached.

The map_prompt default is worth reading rather than replacing. It instructs the model to preserve canvas, composition, geometry, topology, outlines, separator lines, text glyphs and spacing, treats lighting/reflections/gradients as appearance rather than new regions, forbids merging or redrawing regions, restricts output to that 16-colour palette, reserves black for background and genuine holes, and demands no legend, no shading, no new outlines. It's a well-tuned prompt and the short version of the whole node.

enabled false is a no-op: you get a 1×1 placeholder image, an empty cache_key and state: not_generated. The lazy input means the master image isn't even evaluated when it's off, so a disabled branch costs nothing.

The inputs and outputs

  • enabled - off by default. Turn it on when you actually need a map.
  • master_image - one 1024×1024 render. Anything else raises an error about the required canvas.
  • map_prompt - the instruction text. Keep the default unless you have a specific reason; if you do edit it, the cache key changes and you pay again.
  • quality - low / medium / high, default high.
  • seed, map_revision - seed for the generation, and a manual counter to force a fresh map when you changed something the key can't see.
  • model (optional) - gpt-image-2 (default) or gpt-image-2.5-sunburst.

Outputs: color_id_map (the flat map), cache_key (feed it to the cache store or a downstream picker), status (JSON with state, cache hit/stored, and the key).

Install

cd ComfyUI/custom_nodes
git clone https://github.com/TeutonicMepheles/ComfyUI-DAELab-Custom-Nodes-Library.git
# restart ComfyUI

This node is a V3 node, so it needs a current ComfyUI core with comfy_api.latest. If Badge Color ID Map V1 simply doesn't appear in the node list while the rest of the pack does, that's the reason - update ComfyUI rather than pip-installing anything called comfy_api.

Where people get burned

Palette collisions. Sixteen colours for every closed region means a very busy badge will run out. When the model reuses a colour on two adjacent-but-should-be-different regions, your later selection silently covers both. Split the design or accept a coarser region set.

Model creativity. It's a generative call, not a filter. Occasionally it smooths a hairline or thinks a stray highlight is a region. The diagnostics in the pack's own docs are honest that thin gold lines and weak boundaries can come back imperfect; a map_revision bump gives you a re-roll for one more paid call.

Non-square inputs. The map path wants 1024×1024, so a non-square render has to be contain-fitted upstream (the pack's stage does the padding and the nearest-neighbour un-padding for you) - feeding it a 1024×640 will just error, not crop.

Forgetting it's cached per-model. Switching between Sunburst and plain GPT-Image-2 changes the key, so old maps won't be reused. That's correct behaviour and it still surprises people mid-session.

CategoryDAELab/Badge/App

Inputs (7)

NameTypeDefaultDescription
enabledBOOLEANfalse—
master_imageIMAGE—
map_promptSTRINGEdit Image 1 into a flat Color ID Map for masking only. Preserve the exact canvas, composition, geometry, topology, object positions, outlines, separator lines, text glyphs, spacing and every small detail. Treat lighting, reflections, gradients, texture and antialiasing as appearance, not as new regions. Do not merge, split, add, remove, move or redraw a region. Replace every existing closed region with one uniform opaque palette color. Use only: #000000, #FF1744, #00E5FF, #FFEA00, #76FF03, #D500F9, #FF9100, #2979FF, #1DE9B6, #AA00FF, #C6FF00, #FF3D00, #00B0FF, #64FFDA, #E040FB, #7C4DFF. Reserve #000000 for the existing background and genuine holes. Adjacent regions must use clearly different colors. Return only the map: no legend, labels, watermark, shading, texture, glow, depth or new outlines.—
qualityCOMBOhigh3 options: low, medium, high
seedINT60–2147483647—
map_revisionINT00–2147483647—
modeloptCOMBOgpt-image-22 options: gpt-image-2, gpt-image-2.5-sunburst

Outputs (3)

NameTypeDescription
color_id_mapIMAGE—
cache_keySTRING—
statusSTRING—