Resize Mask
Resize a mask to any size — or just the right size for your latent
- mask
- MASK
Masks and latents live at different resolutions, and ComfyUI will happily error out the moment they disagree. A mask generated at 512×512 won't line up with a 1024×1024 latent, and half of "why is my inpaint broken" is exactly that mismatch. Resize Mask is the fix: give it a target width and height, and it returns a mask at that size.
It's from ComfyUI Extended, the dependency-free pack, and it's one of those quiet nodes that prevents an entire class of failures rather than fixing them after the fact.
How it works
Three inputs that matter:
mask(MASK) - what you're resizing.width/height(INT, 0–8192, default 512) - the target. Here's the useful bit: set either one to0and the node preserves the aspect ratio, computing the missing dimension from the other. Set both to0and it passes the mask through untouched.interpolation-nearest-exact,bilinear,area,bicubic, orlanczos(defaultnearest-exact).
Output is a single MASK at the target size. A mask already at the target size is returned as-is without resampling - no wasted work.
The interpolation choice
nearest-exact(default) - no smoothing, fastest, keeps hard edges crisp. Right for masks you'll use as strict cut-outs.bilinear/bicubic- softer edges after resize; handy when you're also planning to blur.area- a good pick for downscaling masks, it averages neighborhoods and holds up better than nearest.lanczos- the highest quality, and the only one implemented via PIL (the others use torch'sinterpolate), so it's the slow one. Reach for it when upscaling a mask matters visually.
Install
cd /path/to/your/ComfyUI/custom_nodes
git clone https://github.com/rookiepsi/comfyui-extended.git
Restart ComfyUI; it's under comfyui-extended/mask. Or ComfyUI Manager → search "ComfyUI Extended" → install → restart. Zero dependencies, no downloads.
Common issues
- 0 × 0 passes through. If both dimensions are zero the mask comes back unchanged - deliberate, but easy to mistake for a bug when you left defaults and nothing happened.
- Hard edges + bilinear = fuzzy cut. If you resize a hard mask with bilinear or bicubic, you get soft edges you didn't ask for. Use
nearest-exactunless feathering is the goal. - Aspect-ratio mode needs a nonzero number. Width 0 + height 0 is the passthrough case, so give one of them a real value if you want the aspect-preserving behavior.
The honest take: it's a utility you'll mostly reach for when something errors or looks wrong. Wire it in front of latent-sized operations and a whole category of "mask size mismatch" bugs stops existing.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| width | INT | 5120–8192 | — |
| height | INT | 5120–8192 | — |
| interpolation | COMBO | nearest-exact | 5 options: nearest-exact, bilinear, area, bicubic, lanczos |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |