To extract an image or consecutive images from a ComfyUI batch, connect the batch to ImageFromBatch, set batch_index to the starting position, and set length to the number of images you want. For example, to select the fourth image alone, use batch_index 3 and length 1, assuming positions are counted from zero. To select the fourth through sixth images, use batch_index 3 and length 3.
Map the requested position to the node inputs
The official ImageFromBatch documentation describes batch_index as the starting index and length as the number of images extracted from that point. In a zero-based index, position 0 is the first image, position 1 the second, and so on. If you identify the desired image using ordinary one-based counting, subtract 1 to get its index.
For a consecutive selection, the last included index is batch_index + length - 1. This calculation is useful for checking your intended range before running the workflow. It does not establish the node's behavior for invalid or out-of-range inputs; the documentation does not specify those cases.
Set up the extraction
- Identify the
IMAGEbatch you want to sample and connect it to the node'simageinput. - Decide the first desired position using the same zero-based counting convention used in your calculation.
- Enter that position in
batch_index. - Enter the number of consecutive images to take in
length. Use 1 for a single image. - Connect the output
imageto a downstream node that can show or otherwise use the resulting batch.
Keep the two integer inputs distinct in your reasoning: batch_index answers “where does selection start?”; length answers “how many images are included?” A value of 3 in length means three images, not an ending index of 3.
Check the requested range before running
Use the worksheet below to translate image positions into inputs. These are hypothetical examples, not measured ComfyUI results. They assume a batch with at least seven images and zero-based indices.
| Intended images, counted from 1 | batch_index | length | Expected indices, counted from 0 | Expected output count |
|---|---|---|---|---|
| Image 1 only | 0 | 1 | 0 | 1 |
| Image 4 only | 3 | 1 | 3 | 1 |
| Images 4 through 6 | 3 | 3 | 3, 4, 5 | 3 |
| Images 6 through 7 | 5 | 2 | 5, 6 | 2 |
After execution, check that the output contains the requested number of images. If you can inspect individual output images in your workflow, compare the first and last against the expected endpoints; for the 4-through-6 example, those should correspond to positions 4 and 6 in the original batch. This catches both a one-position offset and a mistaken length. The node documentation specifies a segment output but does not prescribe a preview method, so use whatever display or downstream inspection your workflow provides.
Diagnose a mismatch or boundary case
If the output count is wrong, first recount the requested images and compare that count directly with length. If the count is right but the content starts too early or too late, revisit the conversion from one-based position to zero-based batch_index. If the final requested position is beyond the batch, the selection is out of range: the documentation does not say whether ComfyUI will reject it, return fewer images, or handle it another way. Do not assume a particular outcome. Choose a range whose final index is within the source batch, or establish the actual behavior in your own workflow before relying on it.
The documented inputs cover one source IMAGE batch, one starting index, and one length. They describe extracting a segment, not selecting scattered positions, reordering images, or cropping image content. For nonconsecutive selections, plan separate selections and a suitable downstream workflow; do not treat length as a list of positions.
Common questions
How do I get just one image? Set `length` to 1 and set `batch_index` to that image's zero-based index. For example, the fifth image has index 4 under zero-based counting.
Does `length` specify the last image's index? No. It specifies the number of images to extract starting at `batch_index`. A selection starting at index 4 with length 2 requests indices 4 and 5.
What happens if the range exceeds the batch? The cited documentation does not define the result for an out-of-range selection. Keep the calculated last index within the known batch, or verify boundary behavior in the ComfyUI workflow you are using.
Sources and next step
This guide interprets public documentation and uses explicitly hypothetical acceptance examples, not application tests. Controls and availability can change; verify the cited manual against your installed version.
For work created in Imagild, carry the input requirements and acceptance checklist into the photo editor. The external software controls discussed above belong to their respective products.