2🐕Mask Expansion
Grow or shrink a mask by a pixel count, positive or negative
- mask
- mask
A mask that's exactly the right shape but too tight - say, an auto-segmented face mask that stops right at the hairline - is one of the most common reasons an inpaint pass leaves a visible ring. EG_ZZ_SSKZ ("Mask Expansion") does the simplest possible fix for that: grow the mask outward by a fixed pixel amount, or shrink it inward, with one number.
How it works
One input beyond the mask itself: extend_size, an integer from -1000 to 1000. Positive values grow (dilate) the mask outward by that many pixels; negative values shrink (erode) it inward. This is the standard "only masked, with padding" move documented for inpainting - cropping and processing just the masked region works much better with some margin around the actual target, typically in the 32–64px range for face and hand fixes, so the model has context beyond the exact boundary you painted.
The inputs and outputs that matter
mask(MASK, required) - the mask to resize.extend_size(INT, required, range -1000 to 1000, default 0) - positive to grow, negative to shrink, in pixels.
Output is a single mask (MASK) - feed it into a crop node, a composite node, or a feathering node like this pack's EG_ZZ_BYYH/EG_ZZ_BSYH/EG_ZZ_HSYH if you want the grown edge softened afterward.
How to install it
ComfyUI Manager: search Comfyui-ergouzi-Nodes. Manual install:
cd ComfyUI/custom_nodes
git clone https://github.com/11dogzi/Comfyui-ergouzi-Nodes.git
Restart. Standard caveat for this pack: the author's README marks this English repo as frozen, pointing to a more actively developed Chinese-named sibling for anything new.
Common issues & troubleshooting
Grown mask now covers content you wanted untouched. Growing by a large extend_size on a mask that's already close to the image edge or to another feature you care about will pull that content into the masked region. Start small - the 32–64px range that's typical for detail-fix padding - before reaching for a larger value.
Sharp edge after expanding. This node changes the mask's shape, not its edge softness - growing or shrinking with extend_size still leaves a hard boundary. If you need a soft transition after resizing, run the output through one of the pack's feathering nodes (EG_ZZ_BYYH for a simple weight/blur pair, or EG_ZZ_BSYH/EG_ZZ_HSYH for Gaussian-kernel control) as a second step.
Negative extend_size erases the mask entirely. Shrinking a mask that's already thin (a fine line, a small detail region) by too large a negative value can erode it down to nothing. If your mask disappears after this node, that's the most likely cause - reduce the magnitude of the negative value.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| extend_size | INT | 0-1000–1000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |