Nodes/ComfyUI-GTF-Utilities/Mask-Crop Inpaint | Post
ComfyUI Node

Mask-Crop Inpaint | Post

Stitch it back, seam-free

By wmpmiles·Created 2 years ago·Updated about a year ago· 5
Mask-Crop Inpaint | Post
  • image
  • mask
  • context
  • resampler
  • image

Mask-Crop Inpaint | Post is the back half of the crop-and-stitch inpainting pair, and it's the node that makes the whole technique look easy. Mask-Crop Inpaint | Pre crops, resizes, and preps your region; this node takes the inpainted output, resizes it back to the original crop size, pastes it into the original image at exactly the right spot, and composites it. If you've got a Pre in your graph, you've got a Post.

Its inputs: image (the inpainted image from your sampler or VAE decode), mask (the composite mask at original full-image resolution - note it's not the cropped mask from Pre), context (the context output from Mask-Crop Inpaint | Pre, which is how it knows where and at what size to paste), and a resampler (same filter architecture as the rest of the pack) for resizing the inpainted crop back up. Output is a single image: the original with only the masked region replaced.

What it does under the hood

This is where the pack earns its "done in linear space" reputation. The node:

  1. Un-shifts the color adjustment Pre applied (if you left color_shift at its 0.5 default, this undoes it).
  2. Trims Pre's padding and resamples the inpainted region back to the original crop resolution using your resampler.
  3. Un-crops it - expands it back onto the full-canvas layout using the bounding box stored in the context.
  4. Composites in linear light: both the original and the inpainted region are converted to linear sRGB, blended by the mask, converted back, and quantized. Compositing in gamma space is how you get visible dark seams at mask boundaries; doing it in linear space is why this looks clean.

The mask input is your control over the blend. Feed it a hard mask and the swap is sharp-edged; feed it a blurred/feathered mask (see Blur Mask, the pack's own tool for exactly this) and the transition softens. That's the difference between "obviously pasted" and "did you even touch this."

Common issues

  • "Invalid context" error - you wired a context from a different Pre, or didn't wire one at all. The context is a required input and must come from the matching Pre node in the same run.
  • Mask resolution mismatch - the composite mask must match the original image resolution and batch size. The node checks and errors loudly; the fix is resampling your mask (via Resample Mask) to the original size before feeding Post.
  • Washed-out inpaint region - usually a color_shift mismatch between Pre (where it's applied) and Post (where it's undone), or you changed Pre's color_shift to 0.5-style handling and Post's resampler is smearing the mask edge. Keep the pair's settings consistent.

Installing

Ships with comfyui-some-image-processing-stuff:

cd ComfyUI/custom_nodes
git clone https://github.com/wmpmiles/comfyui-some-image-processing-stuff

Restart ComfyUI, or ComfyUI Manager → search "Some Image Processing Stuff". No models, no extra dependencies. It's only useful in the context of its Pre twin, so the one-clone install that brings both is the point.

Categoryinpaint

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
maskMASK
contextCONTEXT
resamplerRESAMPLER

Outputs (1)

NameTypeDescription
imageIMAGE