Crop For Inpaint π
Inpaint at full resolution without touching the rest of the frame
- image
- mask
- image
- mask
- stitcher
Here's the dirty secret of whole-frame inpainting: you send the entire image through the sampler, and even the "untouched" pixels get degraded by the VAE encode/decode round trip. The crop-and-stitch pattern exists to fix exactly that - crop around the mask, inpaint only that region, paste it back so every pixel outside the fix is byte-for-byte identical. It's the pattern the knowledge base calls the structural answer to the oldest rule in inpainting, and Crop For Inpaint π is the crop half of it, paired with Stitch Inpaint π.
The payoff is the thing everyone actually wants from inpainting: a 64px eye gets 1024px of generation budget because the crop renders at native resolution, and the rest of the image never passes through a model at all.
What it does
You feed it the image and a mask (white = what to repaint). It grows the mask's bounding box outward by context_factor (default 1.2) so the inpainter sees surrounding context, plus optional flat context_pixels if you want guaranteed padding. It then crops that region and emits:
image- the crop, sized for the sampler.mask- a hard-edged sampling mask matching the crop. By design it is never feathered; feathering lives separately in the stitcher's blend mask, used only at paste time.stitcher- anAUSBOSS_STITCHERthat carries the canvas, the rectangle, the blend mask, and the scale to Stitch Inpaint.
The stitcher is the clever bit: it broadcasts across a video batch, so one crop serves a whole clip. Crop once, run the inpainter over every frame, stitch once.
The inputs that matter
blend_pixels(default 16) - feather width for pasting back. 0 pastes hard. This is not the sampling mask; don't confuse the two.output_multiple(default 8) - rounds crop and target up to a multiple so samplers accept them.target_width/target_height/target_megapixels- rescale the crop to a sampler-friendly area. 1.0 megapixel suits SDXL-class models; 0 keeps native size. Explicit target width/height overrides the megapixel target.mask_grow- dilates (or with negatives, shrinks) the sampling mask so the inpainter repaints past your drawn edge. Different job fromblend_pixels.invert_mask- inpaint everything outside the drawn region.rescale_algorithm- the filter for the sampler round trip.bilinearis the safe default;nearestnever invents pixels.
And the extend_left/right/up/down inputs grow the frame itself for outpainting - the new bands become part of the mask and of the stitched output, which makes this node do outpainting with the same bit-identical guarantee on the original pixels.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/ausboss/ComfyUI-AusBoss.git
Restart ComfyUI and search for AusBoss (ComfyUI Manager: search ComfyUI-AusBoss). No extra Python dependencies for the core pair; fix_edge_halo on the stitch side wants the optional pymatting. Minimum ComfyUI 0.27.1.
Troubleshooting
An empty mask selects the whole image and stitches back unchanged - useful as a passthrough, confusing if you meant to inpaint something and the mask never arrived. If seams show despite a feathered blend, that's blend_pixels being too small or the classic double-blend rim - flip on Stitch Inpaint's fix_edge_halo. And if the crop comes back at the wrong size, check output_multiple isn't rounding it into a different dimension than your sampler expects.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | BHWC image or video frames to crop around the mask. | |
| mask | MASK | White marks the area to inpaint. A multi-frame mask is unioned into one crop window; an empty mask selects the whole image. | |
| context_factor | FLOAT | 1.201β10 | Grows the mask bounding box symmetrically by this factor so the inpainter sees surrounding context. |
| blend_pixels | INT | 160β256 | Feather width for pasting the result back: the paste mask is widened by this many pixels and blurred. The sampling mask is never feathered. 0 pastes hard. |
| output_multiple | INT | 81β128 | Crop and target dimensions are rounded up to a multiple of this so samplers accept them. |
| target_widthopt | INT | 00β16384 | Rescale the crop to this width for the sampler; 0 keeps the native crop width (or follows target_height at the crop's aspect ratio). |
| target_heightopt | INT | 00β16384 | Rescale the crop to this height for the sampler; 0 keeps the native crop height (or follows target_width at the crop's aspect ratio). |
| mask_growopt | INT | 0-256β256 | Dilate the sampling mask by this many pixels (negative shrinks) so the inpainter repaints past the drawn edge. Reshapes what gets painted, unlike blend_pixels which only feathers the paste-back. |
| mask_bluropt | FLOAT | 0.00β64 | Gaussian sigma softening the sampling mask's edge for models that honor soft masks. 0 keeps the hard edge. |
| invert_maskopt | BOOLEAN | false | Inpaint the black area instead of the white area β everything outside the drawn region. |
| context_pixelsopt | INT | 00β4096 | Flat extra context in pixels added around the mask box after context_factor's growth. |
| target_megapixelsopt | FLOAT | 0.000β64 | Rescale the crop for the sampler so its area is about this many megapixels β 1.0 suits SDXL-class models, 0 keeps the native crop size. Explicit target_width/height overrides this. |
| rescale_algorithmopt | COMBO | bilinear | Resize filter for the sampler round trip. bilinear is the safe default, bicubic keeps upscales a touch crisper, area suits heavy downscales, nearest never invents pixels. |
| extend_leftopt | INT | 00β8192 | Outpainting: grow the frame this many pixels leftward. The new band is added to the mask and becomes part of the stitched output. |
| extend_rightopt | INT | 00β8192 | Outpainting: grow the frame this many pixels rightward. The new band is added to the mask and becomes part of the stitched output. |
| extend_upopt | INT | 00β8192 | Outpainting: grow the frame this many pixels upward. The new band is added to the mask and becomes part of the stitched output. |
| extend_downopt | INT | 00β8192 | Outpainting: grow the frame this many pixels downward. The new band is added to the mask and becomes part of the stitched output. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | Cropped BHWC region around the mask, sized for the sampler. |
| mask | MASK | Hard-edged sampling mask matching the crop; never feathered. |
| stitcher | AUSBOSS_STITCHER | Stitch data for Stitch Inpaint π: canvas, rects, blend mask, scale. |