Last Image From Batch
Grab the last N frames, no math required
- image
- IMAGE
Nifty Last Image From Batch is the shortcut you reach for when you keep typing "negative batch index, length -1" into the generic slicer. It takes an image batch and returns the last N images, with the count as the only real input. No index arithmetic, no sign conventions - just "how many from the end do you want?"
Two inputs, one output:
- image - the batch to slice from.
- length - how many images to take from the end (1–4096, default 1).
Output: IMAGE - the last length frames, cloned as a fresh tensor.
Why it exists
"Give me the last frame" is one of the most common batch operations in video workflows, and every implementation makes you think about whether the count is positive or negative and which direction it trims from. This node removes the thinking. It's built directly on the tail slice (image[-length:]), which is exactly the semantics you'd want anyway: length = 1 gives the final frame, length = 4 gives the last four.
Typical uses
- Final-frame still. Render a video, pull the last image, VAE-decode it, save it as a thumbnail or poster.
- Loop ends. Take the last few frames of a generated clip to blend or continue from.
- Best-of cadence. When a batch is ordered best-to-worst or latest-first, the tail is what you actually want.
It's deliberately dumber than Nifty Image From Batch - no start index, no negative anything - and that's the point. When your need is literally "the end of the batch," the dedicated node reads better in a workflow and is harder to misconfigure than the general slicer. If you need to start somewhere other than the end, go back to the full slicer.
Install
Nifty Nodes, standard: 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 tensor slice with a friendly face.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image batch to take the last frames from. | |
| length | INT | 11–4096 | Number of images to take from the end of the batch. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |