Nodes/Link Comfy Nodes/Resize Image and Mask by Side
ComfyUI Node

Resize Image and Mask by Side

Keep your mask perfectly in step while you resize

By Mister-Link·Created 9 months ago·Updated 23 days ago· 0
Resize Image and Mask by Side
  • image
  • mask
  • images
  • mask
length512
interpolation
side

Resize an image and its mask with two separate resize nodes and you're one careless mismatch away from a mask that's off by a pixel, rounds differently, or ends up at a different aspect than the image it's supposed to match. It's a small bug that causes big, confusing downstream problems - inpainting that bleeds into the wrong area, a crop that doesn't line up. Resize Image and Mask by Side does both resizes in one node off a single target, so they're guaranteed to land at identical dimensions.

How it works

You give it a target side length and which side to measure - longer or shorter - and it scales the image (and its mask, together) to hit that length on the chosen side, preserving aspect ratio on the other. That's the same "fit to a max dimension" pattern you'll recognize from most resize nodes; the difference here is that image and mask get exactly the same treatment in the same call, instead of relying on two separate nodes to agree.

The inputs and outputs that matter

  • image and mask - the pair you're resizing together.
  • length (1–16384, default 512) - the target pixel size for whichever side you pick.
  • side - longer or shorter. Pick longer when you need to cap a maximum dimension (common before feeding into a model with a resolution ceiling); pick shorter when you need a guaranteed minimum edge, for instance before a downstream crop or tiling step.
  • interpolation - bicubic, bilinear, or nearest exact. This is worth thinking about specifically because the same setting applies to both the image and the mask. Bicubic and bilinear are the smoother choices and look better on photographic image content, but they can soften a mask's edges into semi-transparent gray rather than keeping it a clean binary cutout. nearest exact keeps hard edges exactly hard - the safer pick when your mask needs to stay crisp, at the cost of a blockier-looking image resize.

Outputs: images and mask, resized together and guaranteed to match.

How to install it

Search "Link Comfy Nodes" in ComfyUI Manager and install from there. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/Mister-Link/link-comfy-nodes
pip install -r link-comfy-nodes/requirements.txt

Restart ComfyUI. Nothing heavy required for this node specifically.

Common issues & troubleshooting

Mask edges going soft when you didn't want them to. If you need a hard binary mask for inpainting or compositing and you picked bicubic or bilinear for image quality, check the mask afterward - it likely picked up some antialiasing along with the image. Switch to nearest exact if that's a problem for your use case.

Picking the wrong side to measure. longer and shorter behave very differently on non-square content. If your output ends up much bigger or smaller than expected, double-check which side you actually meant to constrain - a portrait image resized by its longer side lands very differently than the same image resized by its shorter side.

Feeding it a size that isn't valid for your model. This node only handles the resize-by-side step; it doesn't guarantee the result is divisible by whatever multiple your downstream model requires (commonly 8, 16, or 64). Pair it with Snap to Divisible, also in this pack, if your next step needs a specific divisibility.

Categoryimage/transform

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
maskMASK
lengthINT5121–16384
interpolationCOMBO3 options: bicubic, bilinear, nearest exact
sideCOMBO2 options: longer, shorter

Outputs (2)

NameTypeDescription
imagesIMAGE
maskMASK