Nodes/ComfyUI-Practical-Tools/Image Batch Interleave
ComfyUI Node

Image Batch Interleave

Un-cross your XYZ plot before you save it

By wenchengxiang·Created 2 months ago·Updated 9 days ago· 3
Image Batch Interleave
  • images
  • IMAGE
◄n_groups3►

Batch order in ComfyUI is more meaningful than it looks. An XYZ-plotter or a multi-condition generator doesn't hand you images in the order you'd want to view them - it hands you them in the order it looped, which is usually outer-loop-first. Image Batch Interleave fixes exactly that: it takes a batch and reorders it so frames that belong together end up adjacent.

The mechanism is a classic matrix transpose, and the source explains it better than most READMEs. With n_groups = 3 on a 12-frame batch, it reshapes the batch into 3 groups of 4, transposes, and flattens. Input [1,2,3,4, 5,6,7,8, 9,10,11,12] becomes [1,5,9, 2,6,10, 3,7,11, 4,8,12]. Same frames, same batch size, completely different neighbors - now position-major instead of group-major. That reordering is what turns a batch that was generated in XYZ-loop order into one that walks the frames in the order a contact sheet or an animation sequence actually wants.

When does this matter for real? The sibling node in this pack - Image Batch Count XYZ - exists because batches from XYZ-style workflows carry structure you need to recover. Interleave is the tool that acts on that structure. You'll also see it used when two conditions are generated as two interleaved halves of one batch and you want them matched frame-by-frame instead of block-by-block.

Inputs and outputs that matter

  • images (in) - the batch to reorder.
  • n_groups (in) - how many interleaved streams you're un-crossing, default 3, range 1–1000.
  • IMAGE (out) - the reordered batch, same size.

Two behaviors worth memorizing: if n_groups is 1 (or the batch has one frame), the node returns the batch untouched. And if the frame count isn't divisible by n_groups, it truncates the tail so it fits - with a warning printed to the console, not an error.

Installing it

Part of wenchengxiang/ComfyUI-Practical-Tools. ComfyUI Manager → Custom Nodes Manager → search "ComfyUI-Practical-Tools" → Install → restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools

then restart. No pip dependencies, no model files - pure Python on ComfyUI's bundled stack.

Issues and gotchas

The divisibility truncation is the one real trap - a 10-frame batch with n_groups = 3 silently loses the 10th frame. Check your batch size against n_groups before you run, or you'll be staring at a 9-frame output wondering where one went. And remember the ordering convention: it assumes your batch was already group-major (blocks of frames that belong together). If you feed it a random-order batch you'll get a deterministic but meaningless shuffle. Get the semantics right and it's one of the more quietly useful tools in the pack.

CategoryPractical-Tools/Image

Inputs (2)

NameTypeDefaultDescription
imagesIMAGE—
n_groupsINT31–1000—

Outputs (1)

NameTypeDescription
IMAGEIMAGE—