Nodes/ComfyUI-Desert-Pixel-Nodes/DP Image And String Pairs Switch
ComfyUI Node

DP Image And String Pairs Switch

Pick one image+text pair by index, or cycle them

By DesertPixelAi·Created 2 years ago·Updated about a year ago· 25
DP Image And String Pairs Switch
  • Image_01
  • Image_02
  • Image_03
  • Image_04
  • Image_05
  • IMAGE
  • TEXT
  • INDEX
cycle_modefixed
index1
String_01
String_02
String_03
String_04
String_05

This one keeps an image and its caption glued together. You load up to five image+string pairs, and the switch selects one pair at a time - the image and its matching text come out together, so they can't drift out of sync. It's the fix for a common footgun: when you have five reference images and five matching prompts as separate switches, it's far too easy to select image 3 with prompt 2 and not notice.

Where it shines is any workflow where a picture and a description belong to each other - a reference image with its caption for an IP-Adapter or edit pass, a control image paired with the prompt meant to go with it, or a slideshow where each frame has its own text. Select by index for a specific pair, or set it to cycle and it walks through the set across successive runs.

The inputs that matter

  • index (1–5) - which pair to grab when you want a specific one.
  • cycle_mode - fixed holds on the index you set; increment steps to the next pair each run; decrement steps backward. The increment/decrement modes are what turn this into an automatic batch driver - queue five runs and it serves pair 1, 2, 3, 4, 5 in order.
  • Image_01Image_05 and String_01String_05 (all optional) - your pairs. Fill as many slots as you need; the strings are multiline so full prompts fit.

Outputs: IMAGE and TEXT (the selected pair, wired to wherever they're consumed) plus INDEX (the number that was actually selected - useful for logging or feeding into naming so you can tell which pair produced a given output).

The pattern that makes it worth it

Build your five reference-image / prompt combos once, set cycle_mode to increment, and queue a batch. Each run advances to the next pair automatically, and because the image and text move together, pair integrity is guaranteed - you physically can't mismatch them. That's the entire reason to use a paired switch instead of two independent ones.

How to install it

ComfyUI Manager: search ComfyUI-Desert-Pixel-Nodes, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/DesertPixelAi/ComfyUI-Desert-Pixel-Nodes

then restart. No models, no dependencies. Under the "DP" image category.

Common issues & troubleshooting

It errored / output nothing for a slot. You selected an index whose slot is empty. The inputs are optional, so if you only filled pairs 1–3 and the index lands on 4, there's nothing there. Keep your index range inside the pairs you actually populated, and if you're cycling, make sure every slot in the range is filled.

The cycle isn't advancing. increment/decrement step across executions - a single run shows one pair. Queue multiple runs to see it move, and check cycle_mode isn't stuck on fixed.

The image and text came out mismatched. They shouldn't - that's the node's whole promise. If they look off, confirm you actually loaded them into matching slots (Image_02 and String_02 are a pair), not offset by one. The node pairs by slot number, so a caption typed into the wrong slot rides with the wrong image.

CategoryDP/Image

Inputs (12)

NameTypeDefaultDescription
cycle_modeCOMBOfixed3 options: fixed, increment, decrement
indexINT11–5
Image_01optIMAGE
String_01optSTRING
Image_02optIMAGE
String_02optSTRING
Image_03optIMAGE
String_03optSTRING
Image_04optIMAGE
String_04optSTRING
Image_05optIMAGE
String_05optSTRING

Outputs (3)

NameTypeDescription
IMAGEIMAGE
TEXTSTRING
INDEXINT