Inpaint Prepare
The crop math A1111 did for you, as a node you can see
- image
- mask
- pixels
- mask
- context
What it is
AUTOMATIC1111's inpaint tab hides four decisions inside one denoise slider and two dropdowns: how much of the image to sample, at what size, how much context to include around the mask, and what goes under the mask before denoising starts. In ComfyUI you have to build that yourself, and the fiddly part isn't the sampler - it's getting the mask bounds, the padding and the resize back together so the result can be pasted in the right place.
Inpaint Prepare is that half of the job. It takes an image and a mask, produces a sampling canvas, a mask to match, and a context object that records exactly how it did it - so the matching Inpaint Composite node can put the result back with nothing lost.
The author's own framing says where it stops: "Crop and prepare masks with exact compositing context; use the all-in-one sampler for latent fill modes." Keep that in mind. This node handles pixels and masks; it does not sample.
How it works
area is the first decision. only_masked is the one you'll use: the node finds the mask's bounding box, adds padding pixels around it, expands that box to your width/height aspect ratio without cutting any part of the mask, clamps it to the image, and crops. Then it aspect-preservingly scales that crop up to the canvas and replicate-pads the remainder, so a mask touching the image edge still comes through whole. whole_image skips the bbox and resizes the full frame using resize_mode - stretch, crop or fill.
The mask is feathered before any of that: mask_grow positive dilates, negative erodes (a square morphological pass), then mask_blur applies a Gaussian measured in original pixels. That unit detail matters. Blur 4 on a 4000px photo is a subtle edge; on a 600px crop it's a visible halo. mask_mode = outside inverts the mask first, which is how you outpaint or repaint everything except a subject.
fill is the A1111 masked-content dropdown, and it's worth understanding what's actually implemented. original leaves the pixels alone. fill, latent_noise and latent_nothing all first paint the masked area with surrounding colour - the implementation normalizes several Gaussian-blurred copies at radii of 256/64/16/4, which is a real edge-aware fill rather than a flat grey box. Then the two latent modes need something else: the all-in-one WebUI Inpaint node replaces the masked latent values with noise or zeros so masked source detail can't leak through the VAE into nearby latent pixels. Prepare can't do that - it hands out pixels and a mask, no latent. Which is why the tooltip says latent modes require the all-in-one sampler.
soft_edge and soft_strength add up to 16 extra pixels of Gaussian feathering. The tooltip is blunt about it: "Extra feathering, not AUTOMATIC1111's Soft Inpainting algorithm." Believe it.
Inputs and outputs
You'll actually set four things: area, width/height (multiples of 8, 64–8192), and padding. Everything else has a sane default - blur 4, grow 0, inside, original, stretch - and you should resist fiddling until you have a reason.
pixels- the sampling canvas. → VAE Encode.mask- the canvas-sized mask. → Set Latent Noise Mask (orVAE Encode (for Inpainting)).context- the geometry and original pixels. → Inpaint Composite'scontext. Always both, always from the same Prepare.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/adachi0130/Adachi-Inpaint-Workbench.git
Full restart, then Ctrl+F5. No models, no extra requirements - numpy, Pillow, torch. The pack is MIT licensed and the Windows install.ps1 path works if you'd rather not touch a terminal.
Common issues
"Sampling width/height must be multiples of 8 between 64 and 8192." Not a warning, a hard error. Some samplers want 8, some VAEs want 16 or 32 internally - Prepare rounds the canvas up to the VAE's own compression ratio in WebUI Inpaint, but here you're setting the number yourself.
My output is the wrong size. It isn't. Both sampling areas composite back at the source resolution - that's the point of the design, and the opposite of A1111's whole-image behaviour, where changing the sampling size changed the output size. Use Prepare's pixels and a separate resize node if you want a target-size file.
The crop is bigger than I expected. only_masked expands the bbox to the aspect ratio of your canvas without dropping mask pixels, then pads. A tall thin mask on a square canvas gets a lot of context you didn't ask for. Lower padding before you blame the aspect logic.
Nothing got generated. An empty mask or denoise=0 skips VAE and sampling entirely - the pack treats "nothing to do" as a valid no-op rather than burning a queue slot on a full-frame regen. Check the mask actually has white in it.
Soft edges made the seam worse, not better. Combined blur and growth can eat into what you wanted preserved, and pixels with zero effective mask never change. Try mask_blur down at 4–8 with soft_edge off, and give the sampler more padding instead - context fixes seams better than feathering does.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Original image; output is restored to this exact size. | |
| mask | MASK | White repaints; black preserves. | |
| area | COMBO | only_masked | Whole image or mask bounding-box inpainting. |
| width | INT | 102464–8192 | Sampling canvas width, independent of final image size. |
| height | INT | 102464–8192 | Sampling canvas height. |
| padding | INT | 320–2048 | Mask-only context padding in original pixels. |
| mask_blur | FLOAT | 4.00–128 | Gaussian mask feathering in original pixels. |
| mask_grow | INT | 0-128–128 | Positive dilates; negative erodes the mask. |
| mask_mode | COMBO | inside | Repaint inside or invert the mask. |
| fill | COMBO | original | Original, surrounding-color fill, latent noise, or zero latent. Latent modes require the all-in-one sampler. |
| resize_mode | COMBO | stretch | Whole-image resize mode; mask-only mode always retains the entire mask. |
| soft_edgeopt | BOOLEAN | false | Extra feathering, not AUTOMATIC1111's Soft Inpainting algorithm. |
| soft_strengthopt | FLOAT | 0.500–1 | Adds 0–16 pixels of Gaussian feathering. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| pixels | IMAGE | — |
| mask | MASK | — |
| context | ADACHI_INPAINT_CONTEXT | — |