(deforum) Image Switcher
A boolean that picks between two images — and why that's useful
- image_true
- image_false
- IMAGE
This is a four-line node with a one-line job: if the option boolean is true, pass image_true through; otherwise pass image_false. That's the whole thing. No resizing, no blending, no caching. In a normal static workflow you'd never miss it - but in an animation graph, a switch you can flip with a boolean is quietly the difference between a graph you can script and a graph you rebuild by hand.
What it's for
Think of the places in a Deforum loop where you need to pick between two image sources at runtime:
- Hybrid modes. Feed the live camera feed into
image_trueand your rendered frame intoimage_false, and toggle between them based on a frame counter. - Frame 0 special-casing. On frame 0 you want the init image; on every other frame you want the previous frame. A comparator output driving
optiondoes that branching in pure nodes. - A/B style testing in a loop - swap a stylized version in and out without rewiring.
The pattern works best with the pack's other logic nodes ((deforum) INT Comparator and friends), which produce exactly the BOOLEAN this thing eats. Build a small decision tree in nodes, and the switch becomes the "if statement" at the end of it.
The inputs and outputs that matter
- option (BOOLEAN, default false) - the selector. True routes
image_true, false routesimage_false. - image_true (optional IMAGE) - routed when
optionis true. - image_false (optional IMAGE) - routed when
optionis false.
Output:
- IMAGE - whichever input you selected.
One honest limitation: both inputs must be compatible with whatever consumes the output. If image_true is a batch of frames and image_false is a single image, the downstream node will see mismatched shapes. Keep the two branches the same resolution and batch count.
Installing this pack
It's part of Deforum Nodes by XmYx. ComfyUI Manager: search Deforum Nodes, or:
cd ComfyUI/custom_nodes
git clone https://github.com/XmYx/deforum-comfy-nodes
Restart, let install.py pull the deforum-studio backend and its scientific-Python stack (numpy pinned below 2.0, Python 3.10 required). For a pure logic node like this the heavy install is overkill, but you don't get to install the one node alone - the pack is all-or-nothing.
Common issues
- Nothing comes out. One (or both) optional image inputs are empty and the selected branch is
None. The node happily forwardsNone- it won't error, it just returns nothing downstream. - It toggles once and stays.
optionis a static boolean per queue run unless something drives it from frame data. For per-frame switching, wire it to a comparator that reads the current frame index; don't expect the node to flip itself. - Shape mismatch errors downstream. Both branches should be the same resolution/batch. If they drift, the switch is the wrong tool - blend instead.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| option | BOOLEAN | false | — |
| image_trueopt | IMAGE | — | |
| image_falseopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |