Nodes/SDVN_Comfy_node/⚑️ Crop Inpaint
ComfyUI Node

⚑️ Crop Inpaint

Crop tight around a mask, inpaint at full res, stitch back clean

By StableDiffusionVNΒ·Created 2 years agoΒ·Updated about a month agoΒ· 118
⚑️ Crop Inpaint
  • image
  • mask
  • stitcher
  • cropped_image
  • cropped_mask
β—„crop_size1024β–Ί
β—„extend1.20β–Ί
β—„target_sizetrueβ–Ί

This is the front half of SDVN's built-in crop-and-stitch. If you've done any serious inpainting in ComfyUI you already know why it exists: instead of running your whole image through the sampler to fix a small area, you crop tight around the mask, generate at full resolution on just that region, and paste it back. A 64px eye gets a thousand pixels of generation budget, and every pixel outside the mask stays byte-for-byte untouched - no VAE round-trip smearing your whole frame.

The pattern itself isn't SDVN's invention - it's the lquesada Inpaint-CropAndStitch approach that quietly became the default way people inpaint in 2026, precisely because it turns "remember to composite your result back" from a discipline into a property of the graph. What SDVN did was bake their own crop/stitch implementation into the pack so you don't need the external node set installed at all. Handy if you're already living in SDVN land.

How it works

You feed it your full image and a mask. It finds the mask's bounding box, pads it out, resizes that region to a workable resolution, and hands you back three things: the cropped image, the cropped mask, and a stitcher - an opaque bundle that remembers exactly where the crop came from and how it was scaled. You run the cropped image and mask through your normal inpaint sampler (an inpaint model, InpaintModelConditioning, whatever your stack uses), then hand the result plus the stitcher to its partner node, Loop Inpaint Stitch, which drops the fixed region precisely back into place.

The inputs that matter

  • crop_size - the target resolution the cropped region gets resized to, picked from a list running 512 up to 2048 (default 1024). Match this to your model's native size: 1024 for SDXL/Flux, 512-ish for SD1.5. This is where the detail budget comes from.
  • extend - how much padding to add around the mask's bounding box, as a multiplier (default 1.2, so 20% breathing room). Too tight and the model can't see enough context to blend; too loose and you waste resolution on pixels you didn't need to touch. 1.2 is a sane start.
  • target_size - a boolean toggle for how the output dimensions get resolved. Leave it on the default unless you have a specific reason.
  • image (required) and mask (optional). No mask and it'll crop based on whatever it's given, but the point of this node is a mask.

Outputs are stitcher (STITCHER - carry it to the stitch node), cropped_image (IMAGE - into your sampler), and cropped_mask (MASK - the resized mask for that sampler).

Where it fits

Face and hand fixes, object removal, targeted detail passes - anything where you want to change a small area without the rest of the image drifting. The KB's blunt version of the rule: an edit model like Qwen or Kontext will happily fix what's wrong from a sentence, but it emits a whole new image and unmasked regions come back close-but-not-identical, drifting worse with every pass. Crop-and-stitch is the only route that guarantees the untouched pixels stay untouched. That guarantee is the reason to use this node.

Common issues

The crop looks pasted-on or the scale is off. Usually crop_size mismatched to your model - inpainting at a resolution the model wasn't trained for gives you soft or weird results. Set it to the model's native size.

Not enough context to blend. Bump extend. A mask cropped too tight leaves the model guessing about the surroundings, so seams show. More padding = more context = cleaner blend, at the cost of some detail budget.

Nothing to stitch with. Remember this node is one half of a pair. The stitcher output is meaningless on its own - it only does anything when Loop Inpaint Stitch consumes it. Wire both or you're just cropping.

Installing SDVN_Comfy_node

ComfyUI Manager: search "SDVN_Comfy_node" β†’ install β†’ restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/StableDiffusionVN/SDVN_Comfy_node

Then pip install -r custom_nodes/SDVN_Comfy_node/requirements.txt from the ComfyUI root and restart. The node lands under πŸ“‚ SDVN / 🎭 Mask.

CategoryπŸ“‚ SDVN/🎭 Mask

Inputs (5)

NameTypeDefaultDescription
imageIMAGEβ€”
crop_sizeCOMBO102411 options: 512, 768, 896, 1024, 1280, 1408, +5
extendFLOAT1.200–100β€”
target_sizeBOOLEANtrueGiα»― kΓ­ch thΖ°α»›c Δ‘αΊ§u ra giα»‘ng Δ‘αΊ§u vΓ o
maskoptMASKMask Δ‘αΊ§u vΓ o

Outputs (3)

NameTypeDescription
stitcherSTITCHERβ€”
cropped_imageIMAGEβ€”
cropped_maskMASKβ€”