Prepare Image & Mask for Inpaint
PrepareImageAndMaskForInpaint — the A1111-style inpaint prep ComfyUI doesn't have natively
- image
- mask
- controlnet_image
- inpaint_image
- inpaint_mask
- overlay_image
- crop_region
- controlnet_image
If you came from Automatic1111 and miss "Inpaint only masked" with its blur and padding, this is the node that brings it to ComfyUI. It takes your image and mask and does the fiddly prep A1111 did behind the scenes: blur the mask edges, pad the region, and - the important part - crop tightly to the masked area so the model inpaints that region at full resolution instead of at whatever tiny fraction of the frame it occupies. That crop-and-scale trick is why A1111's "only masked" mode produced such sharp inpaints, and why doing it by hand in Comfy is annoying enough that a purpose-built node is welcome.
Quick reality check first, from the wider inpainting picture: as of 2026, instruction-editing models (Flux Kontext, Qwen-Image-Edit) have taken over a lot of what people used to mask-inpaint, because you can just describe the fix. What they can't do is leave the rest of the image perfectly untouched. When "don't touch anything outside this mask" is the requirement, classic masked inpainting is still the tool - and this node is the front half of that pipeline.
How it works
Given the mask, it finds the bounding box of the masked region, expands it by mask_padding, optionally clamps it to a target width/height, and crops the image and mask to that box. It blurs the mask edge by mask_blur so the inpaint blends instead of leaving a hard seam. Then it outputs the cropped image and mask (ready to encode and sample), plus an overlay and the crop coordinates so you can paste the result back afterward - typically with the pack's OverlayInpaintedImage node.
The inputs and outputs that matter
image/mask- the source and the region to inpaint.inpaint_masked- the whole point.false(default) preps the whole image;trueis the A1111 "only masked" behaviour - crop tight to the mask so the region is inpainted at high resolution. Turn this on for detail work like faces and hands.mask_blur- edge feather, default4(0–64). A few pixels hides the seam; too much and the inpaint bleeds outward.mask_padding- context around the mask, default32(0–1024). More padding gives the model more surrounding image to match, at the cost of resolution on the masked bit. Tune to taste.width/height- force the inpaint area size; leave both at0(default) to let the node size it from the mask plus padding.controlnet_image(optional) - pass a control image through and it gets cropped to the same region, so your ControlNet stays aligned with the inpaint crop.
Outputs: inpaint_image and inpaint_mask (feed these into your VAE encode / sampler), overlay_image and crop_region (hold onto these for pasting back), and the cropped controlnet_image.
How to install it
Part of the Art Venture pack. ComfyUI Manager → search comfyui-art-venture → Install → restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/sipherxyz/comfyui-art-venture
then pip install -r comfyui-art-venture/requirements.txt and restart. No model download.
Common issues & troubleshooting
The inpaint doesn't blend - there's a visible box. Either mask_blur is too low, or you forgot to composite the result back through the crop region. This node preps and crops; you still need to paste the sampled output back onto the original using the crop_region and overlay_image (that's what OverlayInpaintedImage is for). Skip that step and you get a hard-edged patch.
"Only masked" is coming out low-res. That's backwards from the usual complaint - but if mask_padding is huge, the crop is mostly context and the masked bit ends up small in the frame again. Tighten the padding.
My ControlNet is misaligned with the inpaint. Route your control image through the controlnet_image input so it's cropped identically. Feeding an uncropped control image straight to the sampler will misregister against the cropped inpaint.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| mask_blur | INT | 40–64 | — |
| inpaint_masked | BOOLEAN | false | — |
| mask_padding | INT | 320–1024 | — |
| width | INT | 00–2048 | — |
| height | INT | 00–2048 | — |
| controlnet_imageopt | IMAGE | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| inpaint_image | IMAGE | — |
| inpaint_mask | MASK | — |
| overlay_image | IMAGE | — |
| crop_region | CROP_REGION | — |
| controlnet_image | IMAGE | — |