LanPaint Mask Blend
Composite the inpaint back so unmasked pixels stay put
- image1
- image2
- mask
- IMAGE
This little node fixes the one thing everybody forgets about inpainting: the parts you didn't mask come back slightly wrong. Not because the sampler misbehaved - because the whole image round-trips the VAE on the way in and out, and that encode/decode is lossy. Colors lighten, darken, or drift a hair. Do three inpaint passes without fixing it and the image visibly degrades. There's a +356 r/StableDiffusion thread that's basically one long plea about this: please composite your image after inpainting.
Mask Blend is how you composite. You give it your original image, your inpainted result, and the mask, and it stitches them: the masked region comes from the inpaint, everything else comes from the original - pixel-perfect, no VAE degradation on the parts you wanted to keep. It's the single most important habit in an inpainting workflow, and the entire remaining reason to inpaint at all in 2026 instead of just using an edit model: the mask is the guarantee that untouched pixels stay untouched.
How it works
Nothing exotic. It's an alpha composite driven by the mask - masked area takes the new pixels, unmasked area keeps the originals - with a feathered transition band so the seam doesn't show. Because the original pixels are pasted straight back rather than re-decoded, they survive byte-for-byte. This matters especially with LanPaint, which by design generates 100% new content with no built-in blending or smoothing; Mask Blend is the step that puts that new content into the original frame cleanly.
The inputs and outputs that matter
Four inputs, and the whole job is getting two of them straight:
image1andimage2- one is your original image, the other is the LanPaint output. The mask decides which one wins where, so feed both and keep track of which is which; if the wrong region ends up regenerated, swap them.mask- the same mask you inpainted with. This is what says "new pixels here, original everywhere else."blend_overlap- the width of the feathered transition at the mask edge, in pixels. It runs from 1 up to 51 in odd steps (default 1, i.e. basically a hard edge). Nudge it up if you can see a seam; keep it low when you want the boundary crisp.
The output is a single IMAGE - the composited result, ready to save. It wires in wherever a finished image goes.
How to install it
Mask Blend ships inside the LanPaint pack, so if you've already got LanPaint you've got this node. Otherwise: ComfyUI Manager → search "LanPaint" → install, or "Install via Git URL" with https://github.com/scraed/LanPaint.git. Manually, cd ComfyUI/custom_nodes && git clone https://github.com/scraed/LanPaint, then restart ComfyUI (you'll want a version newer than 0.3.11). No model files, no extra dependencies - it's pure image math. You'll find it under the "image/postprocessing" category rather than with the samplers.
Common issues & troubleshooting
- The wrong half got replaced. That's
image1/image2reversed. The README doesn't hard-assign which input is the original, so just swap the two and re-run - one order keeps your background, the other keeps your fill. - Visible seam at the mask edge. Raise
blend_overlapto widen the feather. Too high, though, and the blend bleeds the change into surrounding areas, so creep it up a couple of steps at a time. - "Why do I even need this?" If your unmasked region looks fine without it, you got lucky with a forgiving VAE. Chain a few passes and it stops being fine. As of 2026 the alternative people reach for is the Inpaint Crop and Stitch node pair, which never passes unmasked pixels through the VAE in the first place - but if you're already inside a LanPaint graph, Mask Blend is the one-node fix that's right there.
- Mask doesn't line up. Use the exact mask you fed the sampler, at the same resolution. A resized or re-blurred mask will composite along a slightly different boundary than the one you inpainted.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image1 | IMAGE | Image before inpaint | |
| image2 | IMAGE | Image after inpaint | |
| mask | MASK | — | |
| blend_overlap | INT | 11–51 | The number of pixels to blend between the two images. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |