Nodes/ComfyUI Essentials/πŸ”§ Image Composite From Mask Batch
ComfyUI Node Runs on cloud

πŸ”§ Image Composite From Mask Batch

Image Composite From Mask Batch (ComfyUI Essentials)

By cubiqΒ·Created 3 years agoΒ·Updated about a year agoΒ· 1,155
πŸ”§ Image Composite From Mask Batch
  • image_from
  • image_to
  • mask
  • IMAGE

Blend one image onto another using a mask - but where the twist is in the name: it takes a whole batch of masks and composites frame by frame. It's the node for when your masking varies over a sequence: an animation where the subject moves, a batch of inpaints each with its own region, or any workflow where "paste A onto B" has to happen many times with a different cut-out each time.

Why you'd reach for it

Compositing two images through a single mask is common enough. Doing it across a batch, where each frame needs its own mask, is where the plain single-image composite nodes leave you stitching loops. This node handles the batch natively: give it two images and a stack of masks, and it produces a batch of composites, one per mask. That's the setup you hit in video/animation work and in bulk editing - the mask isn't fixed, it tracks something across frames, and you want the composite to follow.

How it works

For each mask in the batch, it blends image_from over image_to according to that mask - where the mask is white, you see image_from; where it's black, you see image_to; gray gives you a partial blend. Run a batch of N masks through it and you get N composited images out. It's a straightforward A-over-B by mask, just vectorized across the whole stack so you don't manage the iteration yourself.

Inputs and outputs

Three inputs: image_from (the top layer, shown where the mask is active), image_to (the bottom layer, the background), and mask (the batch of masks driving the blend). The output is IMAGE - the batch of results. A key practical point: the counts need to line up sensibly. A batch of masks paired with matching batches (or a single image broadcast) is how you keep frame k's mask applied to frame k's content.

Installing it

From ComfyUI Essentials by cubiq (Matteo Spinelli, the IPAdapter node author). ComfyUI Manager: search ComfyUI Essentials, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/cubiq/ComfyUI_essentials

then restart. It's πŸ”§ Image Composite From Mask Batch under essentials/image manipulation, class ImageCompositeFromMaskBatch+. The pack is maintenance-only as of April 2025.

Common issues

The thing that bites is batch alignment. If your images and masks have mismatched batch sizes, or the frames are in a different order than the masks, you'll get compositing that's technically correct per-frame but wrong overall - the right cut-out on the wrong picture. Make sure the mask batch corresponds to the image batch frame-for-frame. Second, remember masks want to be feathered: a batch of hard masks gives you a batch of seams, so run Mask Blur on the stack first for clean edges. And if the blend looks inverted (foreground where you wanted background), flip which image goes into image_from vs image_to, or invert the masks.

Categoryessentials/image manipulation

Inputs (3)

NameTypeDefaultDescription
image_fromIMAGEβ€”
image_toIMAGEβ€”
maskMASKβ€”

Outputs (1)

NameTypeDescription
IMAGEIMAGEβ€”