Split Image Batch πͺ½
Pull one frame out of a batch, one queue run at a time
- images
- image
- index
- total_count
ComfyUI loves batches. Its loaders happily hand you a tensor with 20 frames, and a pile of nodes happily process that whole batch at once. But not everything does - plenty of per-image nodes expect a single frame, and a batch either errors or runs all 20 through something that was built for one. Split Image Batch is the adapter: it reaches into a batch tensor, pulls out the image at a given index, and hands it downstream one frame at a time.
The neat part is that the index widget has control_after_generate built in, so it auto-increments after every run. Set it once, hit Queue, and each run processes the next image in the batch - the same trick that makes seed widgets step with Auto Queue, applied to "walk through my batch, one frame per generation." That's the intended workflow, and the README is explicit about it: it's the escape hatch when a loop over a huge batch would eat too much memory, because you process each frame in its own run instead of accumulating everything.
How it works
Reading the source, it's three lines of logic and one important detail. total_count is just images.shape[0]. If loop is on, the index is taken modulo the batch size so it wraps around; with loop off, it clamps to the last frame. Then it returns images[index:index+1].
That last bit matters: the output keeps the batch dimension. A lot of "split" nodes strip it and return a shape the rest of your graph silently rejects; this one gives you back a 1-frame batch, which is what every standard IMAGE socket expects. The node also declares IS_CHANGED based on the index, so it reliably re-executes when the counter moves instead of getting stuck in ComfyUI's cache.
The inputs and outputs that matter
images- the batch to split.index- 0-based position, default 0. This is the widget that auto-increments; you set it and forget it.loop- optional, default true. Wraps around when the index passes the end of the batch.
Three outputs: image (the selected frame), index (the actual index used - handy for filenames), and total_count (how many frames were in the batch).
Where people get tripped up
The wrap-around is the one that surprises people. With loop on, an index beyond the batch doesn't error - it silently starts over from frame 0. If that's not what you want, flip loop off and it clamps to the last image instead. And remember the output is still technically a batch of one, so feed it into nodes that accept IMAGE; it's not a "scalar" output and never will be.
Installing
Install via ComfyUI Manager (search ComfyAngel), or:
cd ComfyUI/custom_nodes
git clone https://github.com/ThepExcel/ComfyAngel
Restart ComfyUI. The pack depends on Pillow and nothing heavier - no models, no downloads.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | β | |
| index | INT | 00β999999 | β |
| loopopt | BOOLEAN | true | β |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | β |
| index | INT | β |
| total_count | INT | β |