Get Last Image
Get the Last Image from a batch — boring, tiny, and you'll use it more than you expect
- images
- IMAGE
This node does exactly one thing: it takes a batch of images and hands you back the last one. That's the whole job description, and it's precisely why it keeps showing up in real workflows.
You hit the case for it all the time. You run a batch sampler or a per-frame chain and get back N images, but the next stage only wants one - the final frame of an animation, the last iteration of a progressive upscale, the ending state of a long img2img pass. Reaching for the last element of a batch is the kind of plumbing ComfyUI makes you think about every single time, so having a dedicated node for it beats fiddling with a Select Index or grumbling about it.
How it works
Under the hood it's embarrassingly simple: images[-1:].clone(). It slices off the final frame and clones it so downstream nodes can't mutate your original tensor in place. If you feed it a single image that somehow isn't batched yet, it wraps it with an unsqueeze so it still returns a valid batch-of-one.
One honest caveat: the output keeps its batch dimension. You're getting a tensor shaped [1, H, W, C], not a bare 2D frame - which is what nearly every ComfyUI consumer expects anyway, so it usually doesn't bite. If it does bite, it's because something downstream wanted an unbatched image and you need to handle that yourself.
The one input, the one output
images(IMAGE) - any batch of images. Feed it the output of a VAE decode, a video frame batch, anything.- Output
IMAGE- the last frame of that batch.
Wire it into a preview node, a Save Image, a VAE Encode for the next pass, whatever. It doesn't have opinions, it just hands you the last frame.
It pairs naturally with GetFirstFrame, which is also in this pack - same idea, other end of the batch. Between the two of you can peel off either end of any batch without thinking.
Installing it
This node ships in the ComfyUI-AnotherUtils pack, so you're installing the whole toolbox:
cd ComfyUI/custom_nodes
git clone https://github.com/marcoc2/ComfyUI-AnotherUtils.git
Then restart ComfyUI. Or skip the terminal and use ComfyUI Manager - search for "AnotherUtils" and hit install. Either path gets you every node in the pack, and there's no requirements.txt to fight with, which is a genuinely pleasant surprise in the custom node world.
Gotchas
There aren't many failure modes for a one-line slice, but a couple of things are worth knowing. First, if you're expecting "the last image of a video," remember this operates on the batch you already have - you still need to decode the video into frames first. Second, if your batch has a single image, the node still returns a batch-of-one, so don't go looking for a 2D tensor on the other end. And if you only ever feed it one image, this node is pointless - skip it and wire straight through. It earns its keep when batches are actually batches.
For a pack that mostly does heavy lifting, this is the kind of tiny utility that quietly saves you a headache twenty times a session. Install the pack, drop it in, move on.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |