KJNodes/imagegenerated

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

images
masks
IMAGE
MASK
start_index
0
num_frames
1
KJNodes

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 NameData TypeRequiredDefault ValueRange/OptionsDescription
imagesIMAGENo--images (Input Parameter): Optional image batch input. The node will extract the specified range of images from this data.
masksMASKNo--masks (Input Parameter): Optional mask batch input. The node will extract the specified range of masks from this data.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
start_indexINTYes0-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_framesINTYes11 - 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 NameData TypeDescription
IMAGEIMAGEIMAGE (Output Parameter): The output subset of image segments.
MASKMASKMASK (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.

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.

Loading comments…