Nodes/ComfyUI Impact Pack/Switch (images, mask)
ComfyUI Node Runs on cloud

Switch (images, mask)

Pick one of up to four image+mask pairs with a single number

By ltdrdata·Created 3 years ago·Updated 4 months ago· 3,242
Switch (images, mask)
  • images1
  • mask1_opt
  • images2_opt
  • mask2_opt
  • images3_opt
  • mask3_opt
  • images4_opt
  • mask4_opt
  • IMAGE
  • MASK
select1

A selector for image-and-mask pairs. You wire up to four image inputs (each with an optional mask alongside it), set a number, and Switch (images, mask) passes through the pair you pointed at. It's the manual A/B/C/D switch of a ComfyUI graph: keep several sources connected and flip between them without rewiring. Common uses are toggling between candidate source images, choosing which of several masks to feed a detailer, or building a workflow where an upstream value decides which branch's output continues.

The image and its mask travel together, which is the specific convenience here - you're switching a matched pair in one node, not juggling two separate switches and keeping them in sync.

How it works

You give it a select integer from 1 to 4 and it forwards the corresponding image (and that image's mask, if you connected one) to the outputs. The first image is required and always present; slots 2 through 4 are optional. Point select at slot 2 and out come images2_opt and mask2_opt; point it at slot 1 and you get the required pair. It's a straight pass-through - nothing gets processed, just routed.

The inputs and outputs that matter

  • select (1–4, default 1) - which pair to pass through. This is the whole control surface.
  • images1 (IMAGE) - the first, required image. Always connect this one.
  • images2_optimages4_opt (optional IMAGE) - the other three image slots.
  • mask1_optmask4_opt (optional MASK) - the mask that rides with each image slot.

Outputs: the selected IMAGE and MASK.

How to install it

ComfyUI Manager: search ComfyUI Impact Pack, Install, restart.

Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack
cd ComfyUI-Impact-Pack
pip install -r requirements.txt

Run the pip in ComfyUI's Python environment and restart. No models - it's a routing node.

Common issues & troubleshooting

Error when you select an unconnected slot. This is the one to know: the pack's own docs warn that if the input the selector points at isn't connected, you can get an error. So don't set select to 3 unless slot 3 actually has something wired in. The required first input is your safe fallback.

Selecting the mask but forgetting the image (or vice versa). The pair moves together, but each half is its own optional input. If you connected images2_opt but no mask2_opt, selecting slot 2 gives you the image and an empty mask. That's expected, not a bug - connect the mask if you need it.

select starts at 1, not 0. Unlike the zero-based indexing on some other Impact nodes, this switch is 1–4. Off-by-one confusion between this and, say, String Selector is common.

Want an any-type switch with unlimited slots? This node is fixed to four image+mask pairs. For arbitrary types and growing slots, the pack also ships Switch (Any), which determines its type from whatever you connect. Use this one specifically when you're switching image+mask pairs and want them handled as a unit.

CategoryImpactPack/Util

Inputs (9)

NameTypeDefaultDescription
selectINT11–4
images1IMAGE
mask1_optoptMASK
images2_optoptIMAGE
mask2_optoptMASK
images3_optoptIMAGE
mask3_optoptMASK
images4_optoptIMAGE
mask4_optoptMASK

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK