From bb5c3378894b37809aa7c481134494c795adaf32 Mon Sep 17 00:00:00 2001 From: AbdulRehman Date: Mon, 6 Apr 2026 16:49:49 +0500 Subject: [PATCH] fix: support batch broadcasting in JoinImageWithAlpha node (#12580) The node used min(len(image), len(alpha)) as batch size, so passing a batch of images with a single alpha mask only returned 1 image. Changed to max() with modulo indexing to broadcast the shorter input, matching the behavior of other compositing nodes like ImageCompositeMasked. Co-Authored-By: Claude Opus 4.6 (1M context) --- comfy_extras/nodes_compositing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/comfy_extras/nodes_compositing.py b/comfy_extras/nodes_compositing.py index 3bc9fccb3..5da25a4ac 100644 --- a/comfy_extras/nodes_compositing.py +++ b/comfy_extras/nodes_compositing.py @@ -202,12 +202,12 @@ class JoinImageWithAlpha(io.ComfyNode): @classmethod def execute(cls, image: torch.Tensor, alpha: torch.Tensor) -> io.NodeOutput: - batch_size = min(len(image), len(alpha)) + batch_size = max(len(image), len(alpha)) out_images = [] alpha = 1.0 - resize_mask(alpha, image.shape[1:]) for i in range(batch_size): - out_images.append(torch.cat((image[i][:,:,:3], alpha[i].unsqueeze(2)), dim=2)) + out_images.append(torch.cat((image[i % len(image)][:,:,:3], alpha[i % len(alpha)].unsqueeze(2)), dim=2)) return io.NodeOutput(torch.stack(out_images))