Nodes/ComfyUI/Image Composite Masked
ComfyUI Node Runs on cloud

Image Composite Masked

Paste one image onto another, mask and all — ComfyUI's compositing workhorse

By Comfy-Org·Created 4 years ago·Updated 4 minutes ago· 129,952
Image Composite Masked
  • destination
  • source
  • mask
  • IMAGE
x0
y0
resize_sourcefalse

ImageCompositeMasked is the node behind every "composite after inpainting" advice you've ever read. It takes two finished images - a destination and a source - and pastes the source onto the destination at a position, optionally restricted to the pixels of a mask. That sounds like Photoshop with extra steps. It's actually the difference between a clean multi-pass edit and an image that slowly turns to mush.

Here's the thing nobody warns you about: every time you run an image through VAE encode and decode, pixels drift. Do that to the whole frame a few times in a row and you get the washed-out, ghosted results that made r/comfyui run a "PLEASE composite your image after inpainting" PSA at +356 upvotes. The fix is exactly one node: decode once, paste only the changed region back over the original with this node, and every pixel you didn't touch stays bit-identical. The 2026 crop-and-stitch workflows do this structurally now, but ImageCompositeMasked is still the fallback when you're hand-rolling it.

What it actually does. Feed it destination (the base image) and source (the layer on top), set x and y to where the source's top-left corner lands, and it does the pixel math: where the mask is white (1), the source wins; where it's black (0), the destination shows through. No mask at all means the whole source rectangle gets pasted. It operates on decoded pixels, not latents - that's its sibling LatentCompositeMasked's job.

The inputs that matter:

  • destination / source - both plain images. Keep the original on destination, the edit on source.
  • mask - optional, and the star of the show. Feed it the same mask you inpainted with and only the changed region gets pasted back. ComfyUI masks are white = "where to act", which lines up with this perfectly.
  • x / y - pixel coordinates, top-left origin. Go negative for outpainting: the source simply gets clipped at the canvas edge.
  • resize_source - off by default. Flip it on if your source and destination are different sizes and you want the source stretched to fit the destination's dimensions before compositing.

Where people get burned. The most common beginner mistake is wiring the VAE into it - this node takes images, not latents, so decode first. The second is feeding a PNG into the mask input expecting the node to read its transparency: a mask input wants a MASK, not an image, so split the alpha out first (SplitImageWithAlpha does exactly that). And remember the mask isn't a feather on its own - a hard-edged mask makes a hard-edged seam, so blur it if you want the edit to blend.

Beyond inpainting, it's the glue for a whole range of tricks. Generate a subject and a background separately, composite, then run a low-denoise pass to blend them (that's the classic "AI studio shot" template). Isolate a subject with GroundingDino, blur the background, and composite the sharp subject back on top for a depth-of-field effect. You can even use it to paint the masked region flat black as input to an inpaint-mode ControlNet.

It ships with ComfyUI core - nothing to install, and it loads no model files. It's been there since the early days of the project, so every workflow you download that does any compositing probably already uses it. The name is dry, but it's quietly one of the most-used nodes in the entire graph.

Categoryimage/compositing

Inputs (6)

NameTypeDefaultDescription
destinationIMAGE
sourceIMAGE
xINT00–16384
yINT00–16384
resize_sourceBOOLEANfalse
maskoptMASK

Outputs (1)

NameTypeDescription
IMAGEIMAGE