Nodes/Vantage-Nodes/Switch Image (By Index)
ComfyUI Node

Switch Image (By Index)

Pick one image out of four with an integer — the routing glue for image workflows

By vantagewithai·Created 8 months ago·Updated about a month ago· 25
Switch Image (By Index)
  • image_1
  • image_2
  • image_3
  • image_4
  • image
index0

This is a boring node and it's meant to be. It takes up to four optional image inputs, reads an integer, and passes through whichever image that integer points at. 0 returns image_1, 1 returns image_2, and so on. That's the entire job.

Boring is the point. When you're building a workflow with branching image paths - a face detailer with several candidate fixes, an img2img setup where the input changes per run, a comparison rig that feeds different references into the same downstream nodes - you need a switch. Doing it with manual rewiring is how you accidentally save a workflow pointing at the wrong image and "fix" it for two hours. This node makes the selection a data input, so it can come from a widget, a seed, a scheduler, or another node.

What it needs

  • index - zero-based, 0–3. The tooltip says it plainly: 0 selects image_1, 1 selects image_2. Out-of-range indexes return None instead of erroring.
  • image_1 … image_4 - the candidate images. All optional, all the same IMAGE type, so they're interchangeable slots.

One output: image. If the index is out of range or the selected slot is empty, you get None out, which is either a silent pass-through (if downstream tolerates None) or a wiring error to chase. Worth remembering, because a "why is my image gone?" bug is usually an index pointing at an unplugged slot.

When you'd actually reach for it

The real use case is coupling it to something that computes the index at runtime. A scheduler node that changes index per batch step turns this into a per-iteration image router. A random-integer node turns it into "surprise me between these four references." The standalone use - clicking the index widget - is just a convenience so you don't have to rewire.

It mirrors the pattern of SwitchLatentByIndex and SwitchAny (By Index) elsewhere in the pack; same idea, different data types. If you find yourself wanting more than four slots or a by-name selection instead of by-number, those sibling nodes or a dict-based switcher may serve you better.

Install

Part of Vantage-Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/vantagewithai/Vantage-Nodes.git
pip install -r requirements.txt

or ComfyUI Manager → search "Vantage-Nodes" → Install → restart.

Common issues

  • Output goes dark/empty - index points at an unconnected slot. Check that the index maps to a slot with an actual wire.
  • Off-by-one - it's zero-based. Selecting "the second image" means index 1, and this bites everyone once. The tooltip exists because of us.
  • Only need two images - the node still works fine with two of four slots wired; unused slots are just None.
CategoryVantage/Image

Inputs (5)

NameTypeDefaultDescription
indexINT00–3Zero-based index of the image input to return: 0 selects image_1, 1 selects image_2, and so on.
image_1optIMAGEImage option 1.
image_2optIMAGEImage option 2.
image_3optIMAGEImage option 3.
image_4optIMAGEImage option 4.

Outputs (1)

NameTypeDescription
imageIMAGE