ImageBatchPermute
Rearrange a batch by typing the order you want
- images
- IMAGE
Sometimes you don't want the images in the order a batch gives you. ImageBatchPermute is the node that lets you reorder a batch by typing the sequence you want into a text box - like sorting a playlist by hand. It's part of the Allor Plugin (Nourepide/ComfyUI-Allor), the same pack that gives you ImageBatchJoin and ImageBatchFork, and it fills the "fix the order" gap those two leave behind.
Why would you need to reorder? The compositing and matrix nodes in this very pack can scramble things: ImageCompositeAbsolute in "matrix" mode returns a batch of every A×B pairing, in a predictable but tedious order, and anything that maps batch index to a position (a grid save, a two-image slider, an animation-frame sequence) cares deeply about which image lands where. When a batch comes out in the wrong order, this node is the quick fix.
How it works
You give it a permute string, it extracts every number from that string with a regex, and rebuilds the batch in that order. So "3 2 1" flips a 3-image batch, "4 1 3 2" is a full reorder, and you can even repeat an index to duplicate an image or skip one by just not listing it.
Two details matter. First, indexing is 1-based by default: "1 2 3" means first, second, third. There's a start_with_zero boolean to switch to 0-based if that's how your head works (or if you're feeding it a permute computed elsewhere that already uses 0-based indices). Second, indices are clamped to the batch size - if you ask for image 9 in a 6-image batch, it silently uses the last image rather than erroring. That's convenient for "just fill the rest," and quietly dangerous if a number is off by one. 1-based default is itself the classic footgun: type "1 2 3" and expect image 0, image 1, image 2... no. One-based. Get that wrong and you'll produce a shifted, clamped batch and wonder why.
The output is IMAGE, the same images in the new order - torch.index_select, so it's a zero-copy indexing op, cheap even on big batches.
The inputs
Three required inputs:
- images - the batch you're reordering.
- permute - a
STRING(single line) with the target order, numbers separated however you like (spaces, commas - the regex just grabs the digits). - start_with_zero -
BOOLEAN;false= 1-based indices (default),true= 0-based.
Installing it
Search "Allor" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Nourepide/ComfyUI-Allor
Then restart ComfyUI. It's a batch module, so the pack's rembg/onnx requirements don't touch it, but Manager will install them anyway - that's fine, they're only loaded for the segmentation nodes.
Gotchas worth remembering
- The one-based default is the biggest trap. When in doubt, set
start_with_zerototrueand write indices the way Python would. - Clamping hides typos. A permute like
"2 7"on a 4-batch silently gives you image 2 then the last image, not an error. - This pack auto-updates itself at startup (see
updates.auto_updateinconfig.json), and old installs can hit git errors after the repo's image-stripping rebase - a fresh clone fixes that.
There's not much community chatter about Allor yet, so if a reorder behaves unexpectedly, the author's docs at nourepide.github.io/ComfyUI-Allor-Doc spell out the semantics better than any forum thread will.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| permute | STRING | — | |
| start_with_zero | BOOLEAN | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |