Nodes/ComfyUI_RH_API/πŸ–ΌοΈ RH Image Selector
ComfyUI Node

πŸ–ΌοΈ RH Image Selector

Pick one image out of a batch β€” RH Image Selector

By xuchenxu168Β·Created 9 months agoΒ·Updated 9 months agoΒ· 7
πŸ–ΌοΈ RH Image Selector
  • images
  • image
β—„index0β–Ί

RH Image Selector is the smallest node in the ComfyUI_RH_API pack, and it exists because of a specific annoyance: RH Execute and RH Download return images as a batch tensor - a stack of frames/samples in one IMAGE output. That's great when you want all of them and annoying when you want exactly one. This node slices one image out of the batch by index and hands it back as a single-image tensor.

It's not cloud-specific at all. The pack ships it because multi-image cloud results arrive as batches, but it'll happily index any IMAGE tensor you feed it, from any source. Think of it as a one-liner images[index] in node form.

Inputs and output

  • images - any batch of images. Required.
  • index - which image to pull, 0-based, default 0, range 0–9999. Index 0 is the first image, 1 the second, and so on.

Output: image, a single-image IMAGE tensor you can feed into any normal image input - a KSampler for img2img, a Save Image node, an upscaler, whatever. It keeps the batch dimension (shape 1, H, W, C), so it drops into anything that takes an IMAGE.

How it works

Straightforward: it checks index against the batch size and raises a clear error ("Index X out of range (batch size: N)") if you go past the end, then returns images[index].unsqueeze(0). That bounds check is the whole value - a raw tensor slice would silently give you whatever garbage, while this node tells you the batch only had four images when you asked for index 7.

When you'd actually use it

The common pattern: cloud workflow returns a grid of variations, you want the second one. Run RH Execute, wire images into Image Selector with index: 1, and send that single image into your local post-processing chain. Or in a batch pipeline, select one result per batch before saving. It's a utility node - you won't build a workflow around it, but the day you need to grab "result #3 out of 8," it's the difference between a clean graph and a janky custom-slice workaround.

Gotchas

Zero-based, so the "first" image is index 0 - the classic off-by-one that gets people right after they learn about this node. And because it raises on out-of-range, don't drive it with a hardcoded index if your cloud workflow's output count varies; check the batch size first or you'll get a hard error mid-queue. There's no "last image" or "random" mode; it's a number, in, number, out.

Install is pack-wide: ComfyUI Manager (search ComfyUI_RH_API) or git clone https://github.com/xuchenxu168/ComfyUI_RH_API.git into custom_nodes + pip install -r requirements.txt, restart.

CategoryKen-Chen/RH-API

Inputs (2)

NameTypeDefaultDescription
imagesIMAGEBatch of images
indexINT00–9999Index of image to select (0-based)

Outputs (1)

NameTypeDescription
imageIMAGEβ€”