Nodes/comfyUI-PL-data-tools/Batch Image Getter
ComfyUI Node

Batch Image Getter

Need one image out of a batch? This is the pick

By PnthrLeo·Created 2 years ago·Updated 11 months ago· 2
Batch Image Getter
  • images
  • image
idx0

BatchImageGetter does one thing: it pulls a single image out of a batch by index. In ComfyUI every image is a tensor shaped [batch, height, width, channels], and this node slices one row off the front. That's the whole job, and it's exactly the kind of boring utility you end up needing constantly.

When do you need it? Whenever something hands you a stack and you want just one frame. Video decodes give you a batch of frames. Batch image loaders and seed-variation runs give you stacks. And its sibling in this pack, CloseImagesSearcher, returns its top matches as one batch - so this is the natural way to grab one match out of that. Wire the batch in, set idx, and you've got a single image to preview, save, or route into something that only takes one.

How it works

There's no magic to it. The node returns images[idx].unsqueeze(0) - it indexes into the batch and re-adds the batch dimension so the result is still a proper IMAGE (a batch of one) that any downstream image node accepts. If you ask for an index that doesn't exist, it raises a ValueError with a genuinely helpful message telling you the list has N elements and the valid range is 0 to N-1. That's the entire behavior.

The inputs

Just two, so there's no knobs to fiddle:

  • images - any IMAGE batch.
  • idx - the 0-based index you want, default 0.

Output is the single extracted image as image (IMAGE, batch of one).

The one gotcha

idx is zero-based, so the last image in a batch of 10 is idx = 9. Set it equal to the batch length and you get the out-of-bounds error, not an empty result. Beyond that, there's nothing to tune and nothing to break.

Install

Same as the rest of the pack - there's no README in this repo, so this is just the standard custom-node dance. ComfyUI Manager → Install Custom Nodes → search comfyUI-PL-data-tools → Install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/PnthrLeo/comfyUI-PL-data-tools

then restart. One pack-wide caveat worth repeating here because it takes down all three nodes at once: the pack's __init__ imports everything up front and AreasGenerator imports cv2, which stock ComfyUI doesn't install. So on a clean machine the whole pack fails to load until you run pip install opencv-python in your ComfyUI environment - this node itself needs nothing beyond torch, but you can't reach it until the pack imports cleanly.

Honest take: if you already run WAS Node Suite or any batch-slice node, you don't need this one - it's a convenience so the pack is self-contained, and it's the least interesting node in it. But it's free of extra dependencies, the error message is better than most, and when you want one frame out of a stack it's hard to argue with a node that does exactly that.

CategoryPL Data Tools

Inputs (2)

NameTypeDefaultDescription
imagesIMAGE
idxINT0

Outputs (1)

NameTypeDescription
imageIMAGE