Nodes/Various ComfyUI Nodes by Type/Image Extract From Batch
ComfyUI Node

Image Extract From Batch

Pull one image out of a batch by index

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
Image Extract From Batch
  • images
  • IMAGE
index0

When ComfyUI hands you a batch of images on one wire - four samples from a KSampler, a stack of video frames, the output of a load-sequence node - and you only want one of them, JWImageExtractFromBatch grabs the single image at the index you pick and passes it downstream on its own. It's the "give me item number N" node for image batches.

You hit the need for this constantly once batches enter the picture. Preview just the third frame. Send only the best of four samples to an upscaler. Peel one frame out of a video batch to inspect it. Anywhere a node wants a single image but you're holding a batch, this is the adapter that narrows it down.

How it works

A batch is just several images stacked on one tensor. This node indexes into that stack and returns the one at position index as a batch-of-one. Indexing is zero-based: 0 is the first image, 1 the second, and so on. The rest of the batch is dropped - you get exactly one image out.

The inputs and outputs that matter

  • images (IMAGE) - the batch to pull from.
  • index (INT, default 0) - which image to take, counting from 0. So 0 = first, 2 = third. Wire an INT in to make the selection dynamic (a JWInteger, or a value that changes across runs).
  • Output: IMAGE - the single extracted image.

How to install it

Part of jamesWalker55/comfyui-various, a pack of small utility nodes.

  • ComfyUI Manager: search "Various ComfyUI Nodes by Type", install, restart. Red node in a downloaded workflow? Install Missing Custom Nodes.
  • Manually:
    cd ComfyUI/custom_nodes
    git clone https://github.com/jamesWalker55/comfyui-various
    
    Restart afterward. No models, no dependencies.

Under the jamesWalker55 category after restart.

Common issues

  • Off-by-one - I got the wrong image. Indexing starts at 0, not 1. To get the fourth image in a batch, index is 3. This trips up nearly everyone once.
  • Index out of range. If you ask for an index the batch doesn't have (index 5 in a batch of 4), it can error or clamp depending on the version. Make sure your index is less than the batch size; if you're driving it dynamically, cap it with a JWIntegerMin against batch_size − 1.
  • I actually wanted a range of frames, not one. This node returns a single image. For pulling a slice out of an image sequence, the pack has sequence-specific nodes (the comfyui_image_sequence group) better suited to ranges.
  • Node is red / missing. The pack isn't installed. Install via Manager or clone the repo, then restart.

Small node, but the moment you're working with batches - multi-sample generations or video frames - being able to cleanly peel off one image is exactly the kind of plumbing you end up needing.

CategoryjamesWalker55

Inputs (2)

NameTypeDefaultDescription
imagesIMAGE
indexINT0

Outputs (1)

NameTypeDescription
IMAGEIMAGE