Nodes/ComfyUI-Desert-Pixel-Nodes/DP 3 Images Switch Or Batch
ComfyUI Node

DP 3 Images Switch Or Batch

Pick one of three images, or batch all three

By DesertPixelAi·Created 2 years ago·Updated about a year ago· 25
DP 3 Images Switch Or Batch
  • Image_01
  • Image_02
  • Image_03
  • IMAGE
  • CURRENT_INDEX
modeSwitch_Mode
index1

Two useful behaviors in one small node. Give it up to three images and it'll either route one of them through by index (switch), or combine all the connected ones into a single image batch (batch). It's the image-side twin of the pack's string switches, and it saves you from wiring up a separate selector node and a separate batch node for two jobs that feel like they should be the same node anyway.

It comes from the Desert Pixel pack by DesertPixelAi - a big set of quality-of-life nodes that don't generate anything, they just make routing and organizing a graph less painful. If you've used rgthree's switches, you already understand the shape of this.

How it works

mode decides between the two behaviors and index decides which image wins when you're switching:

  • Switch_Mode - output only the image at index. Use it to A/B between three candidates, or to select which of three source images feeds the next stage.
  • Batch_Mode - stack all connected images into one batch and pass them through together, so downstream nodes process them as a group.

Because the image inputs are optional, you can leave slots empty and only wire the ones you're using. In Batch_Mode it just batches whatever's connected.

The inputs and outputs that matter

  • mode - Switch_Mode or Batch_Mode.
  • index - integer 1 to 3, used in Switch_Mode to pick Image_01, Image_02, or Image_03.
  • Image_01, Image_02, Image_03 - three optional IMAGE inputs.

Outputs: IMAGE (the selected image or the batch) and CURRENT_INDEX (integer). The index output tells you which slot was picked in Switch_Mode, which is handy if you're stepping index through your three inputs and want to know where you are.

If three isn't enough, the 5-input and 10-input versions are identical with more slots. Three is a good default for simple "this, that, or the other" routing.

How to install it

  • ComfyUI Manager: search "Desert Pixel", install, restart. No models, no heavy dependencies.
  • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/DesertPixelAi/ComfyUI-Desert-Pixel-Nodes, pip install -r requirements.txt if present, restart.

The pack's nodes all live under the DP menu.

Common issues

The one real footgun with any image batch is size. Batch_Mode combines images into one tensor, and ComfyUI batches want matching dimensions - if your three images are different sizes, batching can complain or behave oddly. Resize them to a common size first (there are plenty of resize nodes, including ones in this same pack) and batching is smooth.

The other thing: in Switch_Mode, index pointing at an unconnected slot has nothing to output. If you get nothing downstream, confirm index is aimed at a slot you actually wired. And remember index is ignored entirely in Batch_Mode - there, every connected image goes through.

CategoryDP/Image

Inputs (5)

NameTypeDefaultDescription
modeCOMBOSwitch_Mode2 options: Switch_Mode, Batch_Mode
indexINT11–3
Image_01optIMAGE
Image_02optIMAGE
Image_03optIMAGE

Outputs (2)

NameTypeDescription
IMAGEIMAGE
CURRENT_INDEXINT