ComfyUI Node

Reorder Batch

Fix your frame order — reverse, ping-pong loops, and transposing a batch

By einhorn13·Created about a year ago·Updated about a year ago· 1
Reorder Batch
  • images
  • images
  • new_batch_size
mode
columns2

Reorder Batch (class ReorderBatch) reshuffles the order of images in a batch - think animation frames or video, not stills. In ComfyUI, a batch of images is just a tensor where position is meaning: frame 3 of 24, the left column of a sprite sheet. When that ordering is wrong, the whole animation plays wrong. This node fixes it three specific ways, and each one is aimed at a real, boring problem.

The three modes, straight from the source:

  • reverse - flips the whole batch. End becomes start. Trivial, but you'll need it the moment something exports back-to-front.
  • ping-pong - the one most people are here for. It appends the reversed sequence minus its endpoints, so frames 0,1,2,3,4 become 0,1,2,3,4,3,2,1. That's a seamless back-and-forth loop: a camera pan that goes forward, then smoothly returns. With only 2 frames it just appends the first frame, because there's nothing to loop between.
  • row_to_column - transposes a batch as if it were laid out in a grid of columns columns. A 6-frame batch with 2 columns in row-major order - [0,1,2,3,4,5] meaning row1=[0,1], row2=[2,3], row3=[4,5] - becomes [0,2,4,1,3,5], i.e. read column-major. This is for contact sheets and tile-grid workflows where a batch got built in row order but needs to play (or get written) in column order.

The inputs that matter. images, mode (the dropdown), and optional columns (default 2, only used by row_to_column). Outputs are the reordered images plus new_batch_size - handy to confirm what happened, since ping-pong changes the count (a 24-frame batch becomes 46).

Where you'll actually use this: ping-pong when you want a looping video or animation out of a one-way generation, and row_to_column when you tile or pack frames and the read order doesn't match the play order. It's a small node, but it's the kind of thing that saves you from re-running a whole batch because frame 4 was where frame 1 should be.

Install. Same as the rest of this pack - pure torch ops, no dependencies, no models:

cd ComfyUI/custom_nodes
git clone https://github.com/einhorn13/ComfyUI-ImageProcessUtilities

Restart ComfyUI. (Manager search may come up empty since it's not on the official Comfy Registry as of writing; the clone always works.)

Common issues. Mostly nothing to trip on. row_to_column with a batch that isn't an exact multiple of columns just leaves a partial last row - the transposed order is still well-defined, it just won't be a perfect rectangle. And if you chain reorders, remember ping-pong doubles-ish the batch: a second reorder operates on the expanded batch, not the original.

Categoryimage/transform

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
modeCOMBO3 options: row_to_column, reverse, ping-pong
columnsoptINT21–128

Outputs (2)

NameTypeDescription
imagesIMAGE
new_batch_sizeINT