Nodes/comfyui_bmad_nodes/Color (hexadecimal)
ComfyUI Node Runs on cloud

Color (hexadecimal)

Feed hex codes into ComfyUI's color-masking machinery

By bmad4ever·Created 3 years ago·Updated 9 months ago· 70
Color (hexadecimal)
    • COLOR
    hex#000000

    The name undersells it. "Color (hexadecimal)" sounds like a widget you'll never touch, but it's the front door to the color-masking side of this pack. You type a hex code like #FF8800 and get back a COLOR value - a custom type that the pack's other nodes (Color Clip, the color-range builders, color match nodes) consume to know which color you mean. It's how you say "this specific orange" without picking it out of an image.

    Why bother, when you could just sample a color from an image? Because hex is parameterizable. The input is a plain STRING, which means it can come from anywhere a string can: a saved workflow field, a wildcard, or this pack's RequestInputs node in an API setup. You can script a whole batch of color-keyed masks by changing one text value per run instead of re-sampling pixels.

    How it works

    The node validates your input against a hex-color pattern: # followed by either 3 or 6 hexadecimal digits, case-insensitive. So #fff, #FFFFFF, and #ff8800 all pass; ff8800 (no hash) and #GG0000 don't. There's no color math here - it checks the format and passes the string through as a COLOR value for the rest of the pack to interpret.

    That's worth flagging: if you feed it something invalid, it doesn't hard-fail the workflow. It prints a yellow warning to the console and returns the string anyway. Downstream nodes may then misbehave or throw, which can make the actual bug hard to spot. Trust the warning.

    Inputs and output

    • hex - the color code, default #000000.

    The single output is a COLOR. Wire it into any Bmad node that takes a color: Color Clip (clip a color out of an image to build a mask), the color-range nodes, or the find-complementary-color utility. If you're coming from an API workflow, this is the bridge between "my request says #00aaff" and "mask everything that color."

    Install

    Part of bmad4ever/comfyui_bmad_nodes. ComfyUI Manager → search comfyui_bmad_nodes → Install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/bmad4ever/comfyui_bmad_nodes
    cd comfyui_bmad_nodes
    pip install -r requirements.txt
    

    Restart ComfyUI. The pack pulls opencv-python~=4.8.1.78, scikit-image, gray2color, and simpleeval via its requirements.txt; no model files involved.

    Gotchas

    Keep the #. The validator demands a leading hash, and while the error is just a console warning rather than a crash, a hex string without it will quietly flow downstream and confuse every color node it touches. And if a mask you built from a hex color looks slightly off, remember HSV-vs-RGB: the pack does its color math in the color space each node uses, so the same hex can behave differently across nodes - start from the defaults and tune.

    CategoryBmad/image

    Inputs (1)

    NameTypeDefaultDescription
    hexSTRING#000000

    Outputs (1)

    NameTypeDescription
    COLORCOLOR