ImageMask_Swap
Flip two image+mask pairs without breaking the pairing
- image_a
- mask_a
- image_b
- mask_b
- output_image_a
- output_mask_a
- output_image_b
- output_mask_b
ImageMask_Swap is the one-input switch for two image-and-mask pairs: a boolean swap flips which image/mask combo comes out of which output. It exists for the common A/B situation where you have two alternative inputs - two reference images, two mask variants, a base and an edit - and you want to choose between them without re-wiring the graph.
What makes it more than a pair of separate switches is that it swaps the whole bundle. image_a + mask_a travel together, and image_b + mask_b travel together. When swap is off, output_image_a/output_mask_a are A and output_image_b/output_mask_b are B. Flip it on and the outputs exchange places - B's image and B's mask come out of the "a" ports, A's out of the "b" ports. If you've ever switched an image with a generic A/B switch and then watched a downstream node pair a mismatched mask with an image because the two wires crossed, you know exactly why keeping the pair intact matters. It's the same "keep the bundle together" discipline as pipe and context nodes, just at the smallest possible scale.
All four inputs - image_a, mask_a, image_b, mask_b - are required, and the four outputs mirror them. swap defaults to false. That's the entire schema. There's no lazy evaluation here: both branches are fully computed before the node runs, so the cost of the expensive upstream side is paid regardless of which one you end up using. If that matters to you, ImageMask_Switch in the same pack does the lazy version (only the selected branch executes); this node is the simple, eager one.
Where you'd reach for it: an A/B toggle between two mask-heavy inputs where the mask must always match its image - compare-and-swap previews, choosing between two segmented variants, flipping which subject gets pasted into a composite. It's a tiny node, almost embarrassingly simple, and that's fine. Sometimes the right tool is a boolean and four wires.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/Ginolazy/ComfyPanel
# restart ComfyUI
or ComfyUI Manager → "ComfyPanel". No models, no special deps. One thing to keep in mind: because there's no lazy execution, if one of the two branches is expensive (a heavy image process) and you mostly toggle to the other side, you're paying for both every run. That's the case for reaching for ImageMask_Switch instead. For everything else, this is the node you grab when you just want the flip.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image_a | IMAGE | — | |
| mask_a | MASK | — | |
| image_b | IMAGE | — | |
| mask_b | MASK | — | |
| swap | BOOLEAN | false | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| output_image_a | IMAGE | — |
| output_mask_a | MASK | — |
| output_image_b | IMAGE | — |
| output_mask_b | MASK | — |