Nodes/ComfyUI-XJNodes/One Image From Batch
ComfyUI Node

One Image From Batch

Reach into a batch and pull out image number N

By alexjx·Created 10 months ago·Updated 4 months ago· 0
One Image From Batch
  • image
  • IMAGE
index1

One Image From Batch is the simplest possible batch utility: you hand it a batch of images and an index, it hands back one image. That's it. But in a graph editor, "reach into a batch and grab a single frame" is a surprisingly common need with no built-in answer - which is exactly why this node exists.

Think about the workflows where it comes up. You generated a batch of 8 variations and want to send only number 3 through a detailer or an upscaler. You loaded a folder of reference images and want to process them one at a time through a pipeline that can't take a batch. You're comparing generations and want frame 2 of the first batch next to frame 2 of the second. In all of those, the alternative is either re-generating, or wrestling with the batch dimension by hand. The node is the two-second version.

How it works

The mechanics are worth one close look because they're friendlier than they look. The index is 1-based, matching how you'd count on your fingers: index 1 is the first image. It clamps for you - an index below 1 becomes 1, an index above the batch size becomes the last image - so a bad index gives you a usable frame instead of a crash. The output keeps a batch dimension of 1 (shape 1×H×W×C) rather than squeezing down to a 2D array, which means the result drops straight into anything that expects an IMAGE without you fighting tensor shapes.

Inputs and outputs

  • image - the batched IMAGE tensor
  • index - INT, default 1, minimum 1. Which image, counting from 1

The output is a single-image IMAGE (batch dimension 1). That's the whole node - there's no masking, no alpha handling, no fancy options.

Installing it

Same as the rest of the pack. ComfyUI Manager → search "ComfyUI-XJNodes" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-XJNodes
# restart ComfyUI

No dependencies to install - it's a tensor index plus a clamp. Look for it under XJNodes/util.

When it earns its keep (and when it doesn't)

Honest take: this is a glue node, and glue nodes only matter when you're actually gluing. If you batch-generate and immediately preview, you don't need it. The moment you need to feed one of those frames into a pipeline that only accepts single images - a FaceDetailer, a frame-by-frame video pass, a per-image upscale - it's the difference between a clean graph and a contortion act. One sharp edge: since index is a wireable input, you can drive it from a loop counter (the pack's Loop Start index output is a natural fit) and walk through a batch programmatically. That combination - pull frame N, process it, increment - is how you build batch processing without ever flattening the batch yourself. For the random version of "grab some of these," the pack's Random Images From Batch is the sibling that picks several at once.

CategoryXJNodes/util

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
indexINT1

Outputs (1)

NameTypeDescription
IMAGEIMAGE