Imgutils Boolean Logic
When Two Checks Need to Agree
- result
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 signalb(BOOLEAN, default false) - second signalop(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.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| a | BOOLEAN | false | First boolean signal. |
| b | BOOLEAN | false | Second boolean signal. |
| op | COMBO | Logic operation to apply. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | BOOLEAN | — |