KJNodes/imagegenerated

Replace Images In Batch(ReplaceImagesInBatch)

This node takes two image batches (original images and replacement images) as input and performs replacement operations based on user-defined starting indices.

Replace Images In Batch

original_images
replacement_images
original_masks
replacement_masks
IMAGE
MASK
start_index
1
KJNodes

The Replace Images In Batch node receives two image batches (original images and replacement images) as input and performs a replacement operation based on a user-defined starting index.

The Replace Images In Batch node is used to replace specified portions within a sequence of images in bulk. It allows users to start from a defined position and replace corresponding parts of the original image batch with a new set of images, while also synchronously processing associated mask data.

Node Functionality

This node receives two image batches (original images and replacement images) as input and performs a replacement operation based on a user-defined starting index. Internally, if the dimensions of the replacement images do not match the original images, the node automatically scales them to the original image dimensions using the Lanczos algorithm to ensure batch consistency. The node also supports performing the same replacement operation on corresponding mask batches.

Node Parameter Description - Replace Images In Batch

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
original_imagesIMAGENo--: The original image batch, the sequence of images to be partially replaced.
replacement_imagesIMAGENo--: The new image batch used for replacement.
original_masksMASKNo--: The mask sequence corresponding to the original image batch.
replacement_masksMASKNo--: The new mask sequence corresponding to the replacement image batch.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
start_indexINTYes10 - 4096 (Step: 1): Specifies the starting index position for the replacement, range 0 to 4096, step 1.

Output

Parameter NameData TypeDescription
IMAGEIMAGE: The final image batch output after the replacement operation.
MASKMASK: The final mask batch output after the replacement operation.

Usage Scenarios

In workflows for image inpainting or video frame editing, this node can be used when you need to make local modifications to a middle portion of an image sequence (such as video frames). For example, replacing frames 10 to 20 of an original video with another set of generated or edited images, thereby updating local content without affecting other parts of the sequence.

Notes

When using this node, note that the number of replacement images must match the number of available positions from the starting index to the end of the original batch; otherwise, an index out-of-bounds error will occur. Additionally, the input image and mask batches should maintain dimensional correspondence.

The Replace Images In Batch node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…