Nodes/ComfyUI_Mira/Stack Images
ComfyUI Node

Stack Images

Accumulate a batch and grab the last frame

By mirabarukaso·Created 2 years ago·Updated 5 days ago· 206
Stack Images
  • images
  • last_images_in
  • all_images
  • last_image

Two small jobs in one node: it concatenates an incoming image batch onto a running batch you pass in, and it pulls the last frame out of the incoming batch separately. It's a plumbing node for building up a growing collection of images across a loop or a chain, while always keeping a handle on the most recent one.

The pattern it's built for is iterative generation. Say you're running a workflow that produces images in passes - a loop that generates one, feeds the result back in, generates the next - and you want to keep every output in one batch at the end and feed the latest frame forward as the seed image for the next pass. This node does both halves of that bookkeeping in a single step.

How it works

A ComfyUI IMAGE is a batch tensor. This node takes your new images, optionally prepends whatever you passed into last_images_in, and returns the combined stack. If last_images_in is empty (the first time through a loop, say), it just returns images unchanged. Separately, it slices off the final frame of images and returns that on its own output. No model, no processing - just tensor concatenation and a slice.

The inputs and outputs

Inputs:

  • images - the new batch to add (IMAGE). Required.
  • last_images_in - optional prior batch to stack in front of the new one. Leave it unconnected on the first iteration; wire the node's own all_images back into it on subsequent ones.

Outputs:

  • all_images - the accumulated batch (last_images_in + images, or just images if nothing was passed in).
  • last_image - the final frame from images, for feeding forward.

Installing it

Install the pack. ComfyUI Manager: Manager -> Custom Nodes Manager, search ComfyUI_Mira, Install, restart. Or clone:

cd ComfyUI/custom_nodes
git clone https://github.com/mirabarukaso/ComfyUI_Mira.git

Restart; on a load error, pip install -r requirements.txt inside the folder, then restart. No downloads.

Common issues

The thing to get right is the wiring, not the node. In an accumulation loop you feed all_images back into the next iteration's last_images_in - miss that and each pass throws away the history and you end up with only the latest batch. If your final collection keeps coming out short, that feedback connection is the first thing to check.

Second: concatenating image batches requires matching dimensions. If your passes produce different resolutions, the stack will fail - resize to a common size before this node. That's a ComfyUI batch constraint in general, not specific to this node, but it's exactly where an iterative pipeline tends to break.

And if all you actually want is the last frame of a batch, this node gives you that on last_image without you needing a separate batch-index node - a small convenience, but a real one.

Like the rest of ComfyUI_Mira, this is a quality-of-life node from a solo dev (mirabarukaso, of WAI Character Select fame) who built the pack to iron out the rough edges in their own graphs. There's not a big community trail, so the README is the reference if you need to confirm behavior.

CategoryMira/Util/Image

Inputs (2)

NameTypeDefaultDescription
imagesIMAGE
last_images_inoptIMAGE

Outputs (2)

NameTypeDescription
all_imagesIMAGE
last_imageIMAGE