Nodes/imgutils/Imgutils Boolean Logic
ComfyUI Node

Imgutils Boolean Logic

When Two Checks Need to Agree

By xiaden·Created 2 months ago·Updated 2 months ago· 0
Imgutils Boolean Logic
    • result
    afalse
    bfalse
    op

    ComfyUI lets you branch on a boolean - it just doesn't give you an obvious way to combine two of them. That's the gap Imgutils Boolean Logic fills. It takes two boolean signals and runs them through a gate: AND, OR, XOR, NAND, or NOR, with the result coming out as a clean BOOLEAN.

    Where this earns its keep

    Once you have nodes that output booleans - Imgutils Check, Imgutils Label Contains, Imgutils Score Threshold, or any detector-to-gate chain - you'll want compound conditions before you know it. "Run the detail pass only if the image is not monochrome and a face was detected." "Skip this frame if it's greyscale or truncated." A single check gives you a wire; two checks give you a reason to want this node.

    It slots straight into the utility/plumbing layer every workflow quietly runs on - the switch-and-gate stuff the KB's node-plumbing doc calls "the graph as a small program." This is one of the smallest tokens in that language.

    How it works

    Trivial and transparent - it's a lookup table, not a model:

    • AND: true only when both are true
    • OR: true when either is true
    • XOR: true when exactly one is true
    • NAND: the inverse of AND (false only when both are true)
    • NOR: the inverse of OR (true only when both are false)

    The non-inverted gates are the ones you'll use daily; NAND/NOR exist so you can express "not this condition" without adding a NOT node.

    The interface

    Three inputs, one output:

    • a (BOOLEAN, default false) - first signal
    • b (BOOLEAN, default false) - second signal
    • op (dropdown: AND / OR / XOR / NAND / NOR)
    • result (BOOLEAN) - out

    Wire the two checks into a and b, pick the gate, and feed result into a switch, a conditional, or a node that wants a boolean gate (many "if" nodes and for-each framers take one).

    Honest take

    Pure plumbing, and proudly so: no model, no download, instant on CPU. The only friction is that it's strictly two inputs - the moment you're combining three or four conditions you'll be stacking nodes or eyeing something expression-based (the rgthree Power Puter and similar evaluate a little Python mid-graph, which is the heavier hammer). For the common two-signal case, this is cleaner than any of that. One genuine tip: if your graph keeps needing "not X," NAND with a hardcoded true on the other input is a one-node NOT.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/xiaden/comfyui-imgutils.git
    cd comfyui-imgutils
    pip install -r requirements.txt
    

    Or install "imgutils" via ComfyUI Manager. Needs ComfyUI >= 0.25.0 (V3 node API) and Python >= 3.10; the pack depends on dghs-imgutils[gpu]. Nothing to download for this node.

    Troubleshooting

    The classic beginner stumble isn't this node failing - it's feeding it strings instead of booleans. If you're wiring a text output (like a tagger's tags) into a boolean input, it won't fit; use Imgutils Label Contains or Imgutils JSON Filter to convert text into an actual BOOLEAN first. And double-check op when a graph "doesn't behave" - XOR versus OR is the difference between "exactly one" and "at least one," and it's easy to grab the wrong one late at night.

    Categoryimgutils/utility

    Inputs (3)

    NameTypeDefaultDescription
    aBOOLEANfalseFirst boolean signal.
    bBOOLEANfalseSecond boolean signal.
    opCOMBOLogic operation to apply.

    Outputs (1)

    NameTypeDescription
    resultBOOLEAN