Shrink Mask
Pull an overly generous mask back in
- mask
- mask
The mirror image of Expand Mask in this same pack: instead of growing a mask outward for blending room, this one erodes it inward. Less commonly needed than growing - most inpainting advice pushes toward giving the model more margin, not less - but the situation where you want this is real and specific: your mask is bigger than what you actually want changed, and shrinking is how you fix that without repainting it by hand.
When you'd actually reach for this
The usual case is an automatically generated mask - from a segmentation model, an object detector, or an alpha channel - that's a bit too generous around the edges of what you're trying to isolate. Rather than repainting manually, you shrink it a few pixels so the inpaint doesn't creep into pixels you meant to keep untouched. It's also useful as a cleanup step before Mask Bounding Box, if you want your crop region tighter than the raw mask would give you.
Inputs and outputs
- mask - what you're shrinking.
- shrink (INT, default 16, 0–8096) - how many pixels to erode the mask by. Like Expand Mask's
grow, this is a positive-only value; there's no negative-number trick to expand instead - use Expand Mask for that direction. - blur (INT, default 7, 0–8096) - feathers the resulting edge, same as in Expand Mask.
- blur_type - dropdown, defaulting to
gaussian.
Output is a single mask.
Installing it
Comes with the rest of the pack - ComfyUI Manager (search "ComfyUI Inpaint Nodes"), or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Acly/comfyui-inpaint-nodes.git
Restart ComfyUI afterward. No model download needed - pure mask math, same as its sibling node.
Common issues
Shrinking too aggressively can eat your whole mask. If shrink is large relative to the mask's actual width at its narrowest point, you can erode a thin region down to nothing. Start with the 16px default and check the result visually before pushing higher, especially on fine or narrow mask shapes.
Don't reach for this by default. Most inpainting seam problems come from masks that are too tight, not too generous - if you're getting hard edges or visible boundaries in your results, that's usually a job for Expand Mask, not this node. Shrink Mask solves the opposite, less common problem: a mask that's bleeding into territory you wanted to protect.
Blurred edges after shrinking can leave near-1.0 values that aren't quite 1.0, the same numerical quirk covered on Stabilize Mask's page - worth running through that node afterward if you're feeding the result into a noise mask input rather than a straightforward composite.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| shrink | INT | 160–8096 | — |
| blur | INT | 70–8096 | — |
| blur_type | COMBO | gaussian | 3 options: box, linear, gaussian |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |