Nodes/ComfyUI-QuasimondoNodes/Image Blend by Mask (Batch)
ComfyUI Node

Image Blend by Mask (Batch)

Blend two image sequences through a mask (the batch-safe one)

By Quasimondo·Created 2 years ago·Updated about a year ago· 15
Image Blend by Mask (Batch)
  • image_a
  • image_b
  • mask
  • IMAGE
blend_percentage0.50

The stock ComfyUI Image Blend Mask is fine until you throw a batch of frames at it - then it pouts. Image Blend by Mask (Batch) is the author's replacement: same masked-blend idea, but it handles batches of images, which is exactly what you want for compositing video sequences or blending frame-by-frame results. If you're doing any kind of video work or batch compositing in ComfyUI, this is the one you reach for.

What it does

Blend image_a and image_b using a mask, with a global blend_percentage controlling how hard the blend lands. The math, straight from the source: result = image_a * (1 - mask*blend) + image_b * mask*blend. Where the mask is black, you get image_a; where it's white, you get image_b scaled by blend_percentage; gray areas are partial.

The "batch" part is the point, and it's handled sensibly:

  • image_a and image_b must have the same batch size - frame-for-frame.
  • The mask can be a single mask applied to every frame, or one mask per frame. Either is fine.
  • The mask is converted to grayscale using Rec.601 weights (0.299 R + 0.587 G + 0.114 B) - so you can feed it a color image and it'll just work.
  • If the mask's resolution doesn't match the images, it's resized with bicubic interpolation.

That last bit is quietly useful: you can generate a rough mask at a smaller size and let the node upscale it to match, or use a different-sized mask per video segment without hand-aligning everything.

The inputs that matter

  • image_a - background/base batch.
  • image_b - foreground batch.
  • mask - an IMAGE, not a MASK type. That's the gotcha everyone hits the first time: wire in an image (or a mask converted to an image), and it'll be treated as grayscale.
  • blend_percentage - 0 to 1, default 0.5. 0 shows only image_a; 1 fully replaces image_a with image_b where the mask is white. Treat it as the "opacity of the foreground in the masked region."

One output: the blended IMAGE batch, same size as the inputs.

Install

From the Quasimondo pack. ComfyUI Manager → search ComfyUI-QuasimondoNodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Quasimondo/ComfyUI-QuasimondoNodes
cd ComfyUI-QuasimondoNodes
pip install -r requirements.txt

Pure torch/numpy - no models, no special dependencies beyond the pack install.

Where people get burned

The two ValueErrors are the predictable pain points: mismatched image_a/image_b batch sizes, and a mask batch that's neither size 1 nor the image batch size. The node refuses to guess rather than silently misaligning frames - which is the right call, but it means you'll see the error until your batches line up.

Second, remember the mask input wants an image. If you've got a MASK-typed value from a segmentation node, you need to convert it to IMAGE first (or wire it in and let ComfyUI coerce it, which doesn't always happen cleanly). And the blend_percentage default of 0.5 gives you a 50% blend, which reads as a half-wash if you forgot it was there. Set it to 1.0 for a clean "replace where masked" and dial down from there.

Categoryimage

Inputs (4)

NameTypeDefaultDescription
image_aIMAGE
image_bIMAGE
maskIMAGE
blend_percentageFLOAT0.500–1

Outputs (1)

NameTypeDescription
IMAGEIMAGE