Nodes/comfyui-job-iterator/SelectImageBatch
ComfyUI Node Runs on cloud

SelectImageBatch

Pull one image out of a batch by index

By ali1234·Created 3 years ago·Updated 3 months ago· 130
SelectImageBatch
  • images
  • image
select0

Plenty of nodes only want a single image, but plenty of your outputs come back as a batch of several. SelectImageBatch is the small utility that bridges the gap: give it a batch and an index, and it hands you back exactly one image from it - no separate save-and-reload step needed.

How it works

A ComfyUI image batch is a single tensor holding N images stacked together (shape [N, H, W, C]). This node just indexes into that tensor at the position you give it and returns a new one-image tensor for that slot. There's one deliberate kindness in the implementation: if you ask for an index that's out of range - say select = 10 on a batch of 6 - it doesn't throw an error, it quietly clamps down to the last image in the batch instead. Convenient for not crashing a run over an off-by-one, but worth knowing about, because it means a wrong index fails silently rather than loudly.

The inputs and outputs that matter

  • images (IMAGE) - the batch you're pulling from.
  • select (INT, default 0, min 0, max 99999) - the index of the image you want, zero-based. First image in the batch is 0, not 1.
  • image (IMAGE, output) - the single selected image, ready to feed into anything that expects one image rather than a batch.

How to install it

Via ComfyUI Manager: search "comfyui-job-iterator", install, restart. Or clone it directly:

cd ComfyUI/custom_nodes
git clone https://github.com/ali1234/comfyui-job-iterator

Restart ComfyUI afterward. No dependencies to install, no models to fetch - this whole pack is lightweight by design.

Common issues & troubleshooting

You picked an index but got the wrong image, or always the last one. Two likely causes: either your index is zero-based and you were counting from 1, or your index is genuinely out of range and the clamp-to-last-image behavior kicked in silently. Double-check the batch size (a GetImageSize node from the same pack will tell you batch_size directly) before assuming your index is right.

You're feeding it a list instead of a batch and it's not doing what you expect. This node is specifically for a true batch tensor - all images already stacked into one wire. If your images are arriving one at a time out of ComfyUI's list-execution mode (which is what you get downstream of this same pack's JobToList, or from any node with list output), you want SelectImageList instead, not this one. ComfyUI shows both as the same IMAGE type on the wire, so the mismatch doesn't announce itself - it's a backend distinction, not a visual one, and it's the single most common mixup with this pair of nodes.

Nothing changes no matter what index you set. If your "batch" is actually a single image (batch size 1), every index clamps down to that same one image - check upstream that you're really producing more than one image before assuming this node is broken.

Categoryali1234/image

Inputs (2)

NameTypeDefaultDescription
imagesIMAGE
selectINT00–99999

Outputs (1)

NameTypeDescription
imageIMAGE