Nodes/LanPaint/LanPaint Image Decode
ComfyUI Node

LanPaint Image Decode

The node that turns an inpainted latent back into pixels — seams included

By scraed·Created about a year ago·Updated 7 days ago· 1,338
LanPaint Image Decode
  • samples
  • vae
  • image
  • mask
  • image
blend_overlap9

LanPaint_ImageEncode preps the latent, the LanPaint sampler does its "thinking" thing, and then what? Normally you'd reach for VAEDecode, then a MaskBlend node, then an ImageScale to force everything back to the original resolution - the ComfyUI three-step shuffle. LanPaint_ImageDecode is the single node that replaces all three. It decodes the inpainted latent, resizes it to the original image's exact dimensions, and stitches the new pixels into the old image inside the mask.

Why does this exist? Two reasons, both real. First, a VAE decode doesn't always come out the same size as the input - latent padding means your "1024x1024" can decode as 1024x1020. Second, the whole point of masked inpainting is that the unmasked pixels stay untouched: the mask is the guarantee that separates it from full-image edit models like Qwen or Flux Kontext, which re-emit the whole frame and let the background drift. This node is what honors that guarantee on the way out.

How it works

Decode the latent, and if the result is off from the original image's dimensions, resize it (bilinear) to match exactly. Then merge: inside the mask, the inpainted pixels win; outside it, the original image wins - pixel for pixel. At the boundary there's a MaskBlend-style blend whose width is the blend_overlap input, which smooths the seam so the new content doesn't sit there with a visible hard edge. That's the same Gaussian-feathered composite the LanPaint MaskBlend node does, folded in for free.

The inputs that matter

  • samples - the inpainted latent out of your LanPaint sampler.
  • vae - the same VAE the model used; a mismatch here shifts colors, and there's no node that fixes that for you.
  • image (optional) - the original. Give it this and the decode is resized to match it exactly, and the mask merge applies. Skip it and this is just a plain decode.
  • mask (optional) - the inpainting mask, 1 = take inpainted pixels, 0 = keep original.
  • blend_overlap - boundary blend width in pixels, default 9. Bump it up a bit if you see a seam; drop it if the inpainted content is bleeding outside the masked region.

Output is a single image, ready for the next node in your graph.

Install and gotchas

Same pack as everything else - ComfyUI Manager → search "LanPaint", or clone into custom_nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/scraed/LanPaint

then restart. No extra pip dependencies, and it needs ComfyUI > 0.3.11.

The one trap to watch: blend_overlap is a blunt instrument. Too small and you get the classic hard seam; too large and your inpainted region starts eating into untouched pixels. The README also keeps reminding everyone that LanPaint wants binary masks (hardness and opacity maxed) - a soft mask defeats the whole "only the masked part changes" contract. And if your results look broken or "glowing" at the mask edge on recent ComfyUI versions, that's a known thing worth checking (LanPaint issue #80 covers it), not something you did wrong.

Categoryimage

Inputs (5)

NameTypeDefaultDescription
samplesLATENTThe inpainted latent to decode.
vaeVAEThe VAE.
imageoptIMAGEThe original image. When given, the decoded output is resized to its exact dimensions.
maskoptMASKThe inpainting mask (1 = take the inpainted pixels, 0 = keep the original).
blend_overlapoptINT91–51Boundary blend width in pixels between the inpainted and original image (MaskBlend-style).

Outputs (1)

NameTypeDescription
imageIMAGE