ComfyUI Node

Mask Resize

Resize a mask to match your image or latent

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
Mask Resize
  • mask
  • MASK
height512
width512
interpolation_mode

Mask size mismatches are one of the most annoying little errors in ComfyUI. You painted a mask at one resolution, your image or latent is at another, and the moment you try to combine them the graph throws a shape error. This node is the fix: it resizes a MASK to explicit width and height so the two line up.

You reach for it any time a mask has drifted out of sync with what it's supposed to be applied to - inpainting where the mask came from a differently-sized source, a mask you generated at a preview size that now needs to match a full-res image, or a mask you want to reuse across several resolutions. It's plumbing, but it's the plumbing that gets an inpaint graph to actually run.

How it works

You give it a mask and the target dimensions, it scales the mask to exactly those numbers using the interpolation mode you choose. Simple resample - no thresholding, no smart edge handling beyond what the interpolation does.

Inputs and outputs

  • mask - the mask to resize.
  • width and height - the target size in pixels (defaults 512×512). Set these to match whatever the mask needs to align with.
  • interpolation_mode - and this is the choice that actually matters for masks. nearest keeps your mask edges hard and binary, which is what you want when you need a crisp cut. bilinear or bicubic smooth the edges, effectively feathering the mask a little as it scales - sometimes desirable for a softer blend, sometimes not.

Output is a single resized MASK.

Installing it

It's in the comfyui_image_ops file. Install via ComfyUI Manager (search Various ComfyUI Nodes by Type / comfyui-various) or clone:

cd ComfyUI/custom_nodes
git clone https://github.com/jamesWalker55/comfyui-various

Restart ComfyUI. No models, no extra Python dependencies for this node.

Common issues

The one real decision is that interpolation mode, and getting it wrong is the usual complaint. Scale a hard-edged mask with bicubic and you'll get soft gray edges you didn't ask for - which can bleed your inpaint outside the region you meant. If you want the mask to stay a clean binary shape, use nearest. If you actually want a feathered transition, a smooth mode gives you that for free. Pick deliberately rather than leaving it on whatever loaded.

Also worth knowing: this resizes to the exact width and height you type, so if you enter a size that doesn't match your image's aspect ratio, the mask gets stretched to fit. Feed it the same dimensions as the image it's pairing with and you're fine - a quick way to guarantee that is to read the image's size (for instance from a resize node that outputs width and height) and route those numbers straight in.

If the node comes up red as missing when you load a workflow, the pack just isn't installed - these JW nodes are common in shared graphs. Manager's "Install Missing Custom Nodes" or a clone of the repo resolves it.

CategoryjamesWalker55

Inputs (4)

NameTypeDefaultDescription
maskMASK
heightINT5120–99999
widthINT5120–99999
interpolation_modeCOMBO4 options: bicubic, bilinear, nearest, nearest exact

Outputs (1)

NameTypeDescription
MASKMASK