ZML_运算判断
Only run the next step if A beats B
- 任意输入
- A
- B
- 任意输出
- 判断结果
ComfyUI turns into a small programming language once you add conditionals, and ZML_ArithmeticComparison (ZML_运算判断) is a good first taste of that. It compares two values, reports whether the comparison held, and - this is the part that matters - it can stop the graph when the condition fails. "Only save the image if its width beats its height." "Only run the upscaler if this batch is big enough." That's an if-statement you can draw.
What it is
A comparison-and-gate node from ComfyUI-ZML-Image's logic section, in the same family as the pack's switches but with an execution twist. The three required inputs:
- 任意输入 (any type) - the payload. This node is two things at once: a comparator and a pass-through.
- A and B (any type) - the two values being compared.
- 判断条件 - the operator: A大于B (A > B), A小于B (A < B), or A等于B (A == B).
Outputs are 任意输出 (the payload, passed through untouched) and 判断结果 (BOOLEAN - true if the condition held).
The thing to notice: it doesn't compare A and B and then output a result you have to wire into something else. It compares, and gates its own payload output on the outcome. If the condition is false, 任意输出 is an ExecutionBlocker - ComfyUI's mechanism for telling a branch to stop - so whatever you wired downstream simply doesn't run. The boolean output is there for when you want the decision itself as data.
How it works
Under the hood it tries to be smart about what A and B are. The code has explicit handling for image tensors: if you feed it images, it extracts their dimensions and compares (width, height) - that's how the "save only landscape images" pattern works. For plain numbers and strings it falls back to ordinary comparison. Because it's marked as an output node, it anchors execution the way the pack's gates do, and the ExecutionBlocker on a failed condition is the same trick used across this pack's logic and classification nodes.
Install and gotchas
Standard pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image
or ComfyUI Manager → ComfyUI-ZML-Image, restart.
The realistic caveat: mixed types bite. Comparing an image tensor to a string isn't going to resolve cleanly, and while the node handles tensors and numbers, it doesn't promise to compare arbitrary objects sensibly - "up to the node to make sense of the data" is exactly the wildcard-socket deal from the node-plumbing layer. Also remember this isn't >=: A等于B means exactly equal, so a "greater than or equal" workflow needs A大于B on a separate path or a pre-incremented value. And if you wire the payload into something that expects data every run, a blocked run means that node gets nothing - which is the point, but it'll look like a silent failure the first time you forget. Chinese-first UI as always; the English patch from github.com/zml-w/ZZZ_ZML_English_Patch helps. One-person pack, no English community - GitHub issues are the support channel.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| 任意输入 | * | — | |
| A | * | — | |
| B | * | — | |
| 判断条件 | COMBO | A大于B | 3 options: A大于B, A小于B, A等于B |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| 任意输出 | * | — |
| 判断结果 | BOOLEAN | — |