✂️ Inpaint Crop
The node that made masked inpainting sane in ComfyUI
- image
- mask
- optional_context_mask
- stitcher
- cropped_image
- cropped_mask
If you've ever inpainted a small face in a big image and watched ComfyUI grind through the whole 4K frame just to fix a 64px eye, this is the node that fixes that. Inpaint Crop (the shiny new one, class InpaintCropImproved, shown as "✂️ Inpaint Crop") cuts out just the region around your mask, hands you a clean cropped image and mask to sample on, and - crucially - remembers exactly where it came from so its partner node can paste the result back untouched. It's half of a pair: Crop up front, Inpaint Stitch at the end. You basically never use one without the other.
Why bother instead of masking and sampling the whole picture? It's much faster, because you only denoise a crop. It renders that little region at your model's native resolution - crop a 64px area, blow it up to 512 or 1024, generate real detail, shrink it back. And it never passes the unmasked part of your image through VAE encode/decode, the single biggest cause of the whole picture subtly shifting color every pass. That last property is why this pack became the community default in 2025-26: the old "please composite your image after inpainting" discipline stops being something you remember and becomes a property of the graph.
How it works
Give it an image and a mask. It fills holes in the mask, optionally grows or blurs it, figures out a bounding box that includes some context around the masked area, crops to that box, and resizes the crop to a target resolution you pick. Out come three things. You sample on the crop like any normal img2img/inpaint workflow, then feed the result back to Stitch.
The one non-obvious output is stitcher - not an image, but a bundle of "here's where this crop lives and how it was transformed." Don't wire it anywhere except Stitch. It's the receipt that makes the paste-back pixel-perfect.
The inputs and outputs that matter
Most of the two dozen knobs have sane defaults. The handful a beginner actually touches:
mask(optional MASK) - the region you're regenerating. This is the whole point; wire your mask here.output_target_width/output_target_height(default 512×512) - the resolution the crop gets resized to. Set this to your model's native res: 512 for SD 1.5, 1024 for SDXL or Flux. Leaveoutput_resize_to_target_sizeon.context_from_mask_extend_factor(default 1.2) - how much surrounding image to include for context. 1 = just the mask, 2 = grow it by the mask's size in every direction. More context means the model understands the scene better; too much and you waste resolution on stuff you don't care about.mask_blend_pixels(default 32) - grows and blurs the stitch mask so the paste blends with no visible seam. The default is usually fine.device_mode(defaultcpu (compatible)) - CPU always works but is slow;gpu (much faster)is 30-100x faster (inputs must fit in VRAM). The default was flipped back to CPU in mid-2026 for compatibility, so switch to GPU yourself if the node is a bottleneck.
There's also extend_for_outpainting (with per-direction factors) to grow the canvas, preresize to force a min/max resolution first, plus mask_fill_holes, mask_expand_pixels, and mask_hipass_filter (ignores near-black mask values below 0.1). Ignore most of those until you need them.
Outputs: cropped_image and cropped_mask go into your sampling chain, and stitcher goes straight to Inpaint Stitch.
How to install it
Search ComfyUI-Inpaint-CropAndStitch in ComfyUI Manager and install, or drop to a terminal:
cd ComfyUI/custom_nodes
git clone https://github.com/lquesada/ComfyUI-Inpaint-CropAndStitch.git
then restart ComfyUI. There are no model downloads and no heavy dependencies for the nodes themselves - it's pure image and mask math (GPL-3.0, by Luis Quesada Torres). The example workflows in the repo pull real models (a Flux GGUF, an inpainting ControlNet, 4x-UltraSharp), but that's the workflow's requirement, not the node's.
Common issues & troubleshooting
"I can still see the original image through my inpaint." This is the number-one report and it's almost always the mask, not the node. Your mask isn't 100% opaque - even shades of grey your eye reads as white count as partial mask. The author's own advice: screenshot it and check the pixels are actually 255,255,255 / #FFFFFF. If you use fill-holes, make sure the whole boundary is pure white too.
Denoise is stuck at 1 / the fix ignores the original. Use InpaintModelConditioning in your sampling chain instead of "VAE Encode (for Inpainting)" - that's what lets you run denoise below 1 for subtle changes. And use an actual inpainting checkpoint (e.g. a ...Inpainting variant) for clean edges.
Double heads or doubled bodies in the crop mean you upscaled a region larger than the model wants to draw one subject in. Downscale instead, or lower the target resolution.
It's slow on video. Switch device_mode to gpu (much faster) - both crop and stitch move to VRAM and get dramatically faster, as long as the inputs fit.
Inputs (27)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| downscale_algorithm | COMBO | bilinear | 6 options: nearest, bilinear, bicubic, lanczos, box, hamming |
| upscale_algorithm | COMBO | bicubic | 6 options: nearest, bilinear, bicubic, lanczos, box, hamming |
| preresize | BOOLEAN | false | Resize the original image before processing. |
| preresize_mode | COMBO | ensure minimum resolution | 3 options: ensure minimum resolution, ensure maximum resolution, ensure minimum and maximum resolution |
| preresize_min_width | INT | 10240–16384 | — |
| preresize_min_height | INT | 10240–16384 | — |
| preresize_max_width | INT | 163840–16384 | — |
| preresize_max_height | INT | 163840–16384 | — |
| mask_fill_holes | BOOLEAN | true | Mark as masked any areas fully enclosed by mask. |
| mask_expand_pixels | INT | 00–16384 | Expand the mask by a certain amount of pixels before processing. |
| mask_invert | BOOLEAN | false | Invert mask so that anything masked will be kept. |
| mask_blend_pixels | INT | 320–64 | How many pixels to blend into the original image. |
| mask_hipass_filter | FLOAT | 0.100–1 | Ignore mask values lower than this value. |
| extend_for_outpainting | BOOLEAN | false | Extend the image for outpainting. |
| extend_up_factor | FLOAT | 1.000.01–100 | — |
| extend_down_factor | FLOAT | 1.000.01–100 | — |
| extend_left_factor | FLOAT | 1.000.01–100 | — |
| extend_right_factor | FLOAT | 1.000.01–100 | — |
| context_from_mask_extend_factor | FLOAT | 1.201–100 | Grow the context area from the mask by a certain factor in every direction. For example, 1.5 grabs extra 50% up, down, left, and right as context. |
| output_resize_to_target_size | BOOLEAN | true | Force a specific resolution for sampling. |
| output_target_width | INT | 51264–16384 | — |
| output_target_height | INT | 51264–16384 | — |
| output_padding | COMBO | 32 | 8 options: 0, 8, 16, 32, 64, 128, +2 |
| device_mode | COMBO | cpu (compatible) | 2 options: cpu (compatible), gpu (much faster) |
| maskopt | MASK | — | |
| optional_context_maskopt | MASK | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| stitcher | STITCHER | — |
| cropped_image | IMAGE | — |
| cropped_mask | MASK | — |