Nodes/KJNodes for ComfyUI/Get Images From Batch Indexed
ComfyUI Node Runs on cloud

Get Images From Batch Indexed

Pull specific frames out of a batch by index

By kijai·Created 3 years ago·Updated a day ago· 3,011
Get Images From Batch Indexed
  • images
  • IMAGE
indexes0, 1, 2

Sometimes you don't want a contiguous slice of a batch - you want these specific frames: 0, 5, and 12, say. The stock "get from batch" nodes tend to think in ranges (start + length). GetImagesFromBatchIndexed lets you just list the indices you want and get exactly those images back, in the order you listed them. It's a small thing, but the moment you need frames 0, 7, and 30 out of a 60-frame batch, nothing else does it as cleanly.

Handy for grabbing keyframes, sampling every Nth frame for a preview, pulling the first and last frame of a clip, or reordering - since the output follows your list order, you can reshuffle a batch just by listing indices in a new order.

How it works

You type a list of indices, it returns those images as a new batch. That's the whole node. It reads your string like 0, 5, 12, plucks those positions out of the input batch, and stacks them into an output batch in that sequence. Duplicate an index and you get that frame twice; reorder them and the output reorders to match.

It's one of a little family of "indexed" batch nodes in KJNodes - get, insert, and their latent equivalents - that exist because manipulating batches by explicit index is exactly the kind of fiddly thing you don't want to script by hand every time.

The inputs and outputs that matter

  • images (IMAGE) - the batch to pick from.
  • indexes (STRING, default 0, 1, 2, multiline) - the positions you want, comma-separated. Zero-based, so the first frame is 0. Order matters: 2, 0, 1 returns them in that order.

Output is IMAGE - a new batch containing exactly the frames you named, ready to send onward.

That's it. No other knobs.

How to install it

ComfyUI Manager: search KJNodes for ComfyUI, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-KJNodes
pip install -r ComfyUI-KJNodes/requirements.txt

Restart and it's under KJNodes/image. No models, minimal dependencies.

Common issues & troubleshooting

Index out of range. The indices are zero-based, so a 10-frame batch has valid indices 0 through 9 - asking for 10 points past the end. Off-by-one here is the classic mistake: "the tenth frame" is index 9, not 10.

I got the wrong frames. Double-check you're counting from 0. If you expected frame 1 to be the very first image, that's index 0. It trips everyone up once.

I want a continuous range, not a list. You can list 0, 1, 2, 3, 4, but if you always want a start-and-count slice, a range-style batch node is less typing. This node's advantage is arbitrary, out-of-order selection - lean on it when the frames you want aren't contiguous.

Formatting. Keep it to plain integers separated by commas. Stray characters or non-numbers in the string will trip the parse. Whitespace around the commas is fine.

CategoryKJNodes/image

Inputs (2)

NameTypeDefaultDescription
imagesIMAGE
indexesSTRING0, 1, 2

Outputs (1)

NameTypeDescription
IMAGEIMAGE