Get Image or Mask Range From Batch(GetImageRangeFromBatch)
This node accepts two types of data as input: IMAGE and MASK, both of which are optional.
Get Image Range From Batch
The Get Image or Mask Range From Batch node accepts data of two types, IMAGE and MASK, as input, both of which are optional.
The Get Image or Mask Range From Batch node is a tool for extracting a specified range of segments from a batch of image or mask data. Its core function is to slice a continuous subset from the input batch of images or masks based on user-defined start position and count, and output them separately.
Node Functionality
This node accepts data of two types, IMAGE and MASK, as input, both of which are optional. Its internal logic independently processes the image and mask data streams, performing slicing operations based on the same start index and frame count parameters. When the start index is set to -1, the node automatically calculates the starting position from the end of the sequence, ensuring that the specified number of frames from the end can be retrieved.
Node Parameter Description - Get Image or Mask Range From Batch
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
images | IMAGE | No | - | - | images (Input Parameter): Optional image batch input. The node will extract the specified range of images from this data. |
masks | MASK | No | - | - | masks (Input Parameter): Optional mask batch input. The node will extract the specified range of masks from this data. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
start_index | INT | Yes | 0 | -1 - 4096 (Step: 1) | start_index (Input Parameter): Specifies the frame index to start extraction from. Setting it to -1 means calculating the start point by counting backwards from the end. The valid range is -1 to 4096. |
num_frames | INT | Yes | 1 | 1 - 4096 (Step: 1) | num_frames (Input Parameter): Specifies the number of consecutive frames to extract from the batch. The valid range is 1 to 4096. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| IMAGE | IMAGE | IMAGE (Output Parameter): The output subset of image segments. |
| MASK | MASK | MASK (Output Parameter): The output subset of mask segments. |
Usage Scenarios
This node is very useful in workflows involving video frame processing or animation sequence editing. For example, when you have a batch of generated multi-frame images but only need a specific segment for subsequent refinement or special effects processing, you can use this node to precisely extract the required part and then pass the result to the next image processing node.
Notes
When using this node, note that the input image and mask batches are processed independently, but they share the same start index and count parameters. If both images and masks are provided, ensure their batch lengths are sufficient to support the same slice range; otherwise, errors may occur due to length mismatches.
Get Image or Mask Range From Batch Node Source Code Link
The Get Image or Mask Range From Batch node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.