Nodes/Image Misc/Resize Mask (KJ/SET)
ComfyUI Node

Resize Mask (KJ/SET)

Resize a mask without painting gray fringes on it

By set-soft·Created about a year ago·Updated 8 months ago· 2
Resize Mask (KJ/SET)
  • mask
  • get_image_size
  • mask
  • width
  • height
width512
height512
keep_proportionsfalse
upscale_methodnearest-exact
crop

Masks are not images, and resizing them like images is how you get fuzzy gray edges where there should be a clean black/white boundary. This node is the dedicated, simplified mask resize from the Image Misc pack - a port of Kijai's KJNodes node - and its whole point is that it defaults to nearest-exact interpolation, which snaps pixel values instead of averaging them. Resize a hard mask with bicubic and every edge becomes a soft ramp; with nearest-exact, it stays crisp. That one default is the feature.

It's a smaller surface than the pack's image resize node, deliberately: mask in, width/height, a couple of options, mask out. You reach for it when you have a mask that needs to match a different image's dimensions - upscaling a low-res inpainting mask to full-res, or aligning a mask to a ControlNet canvas - without the risk of interpolation artifacts polluting your alpha.

Inputs and outputs

  • mask - the mask (or batch of masks) to resize.
  • width / height - target size. Set one to 0 to keep the input's dimension on that axis.
  • keep_proportions - on, maintain aspect ratio and fit within the target (one dimension may come out short); off, force the exact size.
  • upscale_method - defaults to nearest-exact. The other four (bilinear, area, bicubic, lanczos) are there if you genuinely want a soft mask; for a hard selection mask, leave it.
  • crop - disabled or center; center-crops to the target size after resizing.
  • get_image_size (optional) - wire an image here and its dimensions become the target, overriding width/height. The classic "make this mask match that image" move.

Outputs are mask, plus width and height ints reporting the actual result - useful if you let 0-sizing or proportions decide for you and need the number downstream.

Installing it

Part of Image Misc:

cd ComfyUI/custom_nodes
git clone https://github.com/set-soft/ComfyUI-ImageMisc
cd ComfyUI-ImageMisc && pip install -r requirements.txt

or ComfyUI Manager → "Image Misc", then restart. Under image/manipulation.

Where it fits

Use it whenever a mask and an image are about to meet in a composite or an inpainting step and their dimensions don't line up. The get_image_size input is the standout - it's the SET addition over KJNodes, and it means "resize to match that image" is one wire instead of reading dimensions and typing them. Two small cautions: if you do pick lanczos, the node internally handles masks specially (it replicates to three channels, resizes, and takes the red channel back) so it still works, and keep in mind keep_proportions can leave you short on one axis - pair it with crop: center if you need to fill the target exactly. For plain mask resizing, though, this is the node to keep wired in.

Categoryimage/manipulation

Inputs (7)

NameTypeDefaultDescription
maskMASK
widthINT5120–16384Used when no `get_image_size` is provided
heightINT5120–16384Used when no `get_image_size` is provided
keep_proportionsBOOLEANfalse
upscale_methodCOMBOnearest-exactInterpolation method for image resize
cropCOMBO2 options: disabled, center
get_image_sizeoptIMAGEImage size to use as reference

Outputs (3)

NameTypeDescription
maskMASK
widthINT
heightINT