Image From Batch
Pull frame 12, or the last 4, out of a batch of images
- image
- IMAGE
Everything in ComfyUI that touches multiple frames hands you a batch - one tensor with a batch dimension holding N images. Sometimes you want all of them. Sometimes you want exactly one: the best frame from a grid, the last frame of a video, a single shot to feed into img2img. Nifty Image From Batch is the slicer for that: give it a batch, a start index, and a length, and it returns the slice you asked for.
The two numbers that matter:
- batch_index - where to start. Positive counts from the beginning (
0= first image). Negative counts from the end (-1= the last image). Range ±4096. - length - how many to take.
-1means "everything from start to the end of the batch," which is the trick to remember:batch_index+length = -1gives you "all frames from here onward," the classic last-half-of-a-video grab. Otherwise it's a plain count.
Output: IMAGE - the extracted slice, as a fresh copy (it clones the tensor, so downstream changes won't corrupt the source batch).
Where you'll actually use it
- Grid → single. A batch of 4×4 previews; pull the one you like and feed it to VAE Decode or img2img.
- Video tail work. Grab the last N frames of a generated clip for a seamless loop or a final-frame still.
- Interleaving and selection. Combined with a Nifty Math index, it becomes a computed frame picker - "every 3rd frame," "the middle frame," and so on.
The negative-index convention is the thing people stumble on: batch_index = -1 means "the last image," not "start before the beginning." Once that clicks, the node is intuitive. And because it takes a plain batch tensor, it sits happily between a VAE Decode and anything downstream that expects a smaller batch.
One small note on scope: this is images. If you're slicing latents, Nifty Latent From Batch is the matching node, and it handles 4D and 5D (video) tensors; the image version here only deals with the image batch dimension.
Install
Nifty Nodes, standard install: ComfyUI Manager → search "Nifty Nodes", or
cd ComfyUI/custom_nodes
git clone https://github.com/Stibo/comfyui-nifty-nodes
Restart ComfyUI, keep ComfyUI current (v3 API). No extra dependencies - it's a pure tensor slice.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image batch to slice from. | |
| batch_index | INT | 0-4096–4096 | Start index within the batch. Positive = from the beginning, negative = from the end (-1 = last image). |
| length | INT | 1-1–4096 | Number of images to take. -1 = take all from start to end of batch. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |