Nodes/Node - Size Matcher/Size Match Images/Masks
ComfyUI Node

Size Match Images/Masks

The Node That Ends the Resize-Chain Spaghetti

By christian-byrne·Created 2 years ago·Updated 2 years ago· 5
Size Match Images/Masks
  • image_1
  • image_2
  • mask_1
  • mask_2
  • IMAGE
  • IMAGE
  • MASK
  • MASK
method

Every compositing workflow eventually hits the same wall: you have two images that need to be the same size, and they aren't. The classic fix is a teetering tower of Resize, Pad, and Crop nodes that you rebuild every single time. This node collapses that tower into one drop-down. It takes any two images, masks, or an image-and-mask pair and makes them exactly the same size using a method you pick. That's the whole job, and it does it cleanly.

It's one of two nodes in the size-match-compositing-nodes pack by christian-byrne. No models to download, no API, no key - just tensor math on the GPU. It's a tiny, self-contained utility, and it shows in a good way.

How it works

You connect exactly two of the four optional inputs - image_1, image_2, mask_1, mask_2 - and pick a method. Any pairing works: image-vs-image, mask-vs-mask, or a mask against the image it came from (handy right before a composite step). The node then returns both tensors resized to identical dimensions.

The method enum is where the real thinking happens. Seven options, and they divide into two philosophies:

  • Resize the smaller one up to match the larger: cover_crop_center and cover_crop scale to cover then crop the overflow (center vs. top-left), fit_center scales to fit inside and pads the leftover space, center_dont_resize pads without scaling at all, and fill just stretches - yes, it distorts the aspect ratio.
  • Crop the larger one down to match the smaller: crop_larger_center and crop_larger_topleft. The smaller image is never touched.

The larger image only stays untouched in the crop methods; everywhere else it's the anchor and the smaller one gets fitted to it.

The outputs, and the trap

The node always exposes four outputs - two IMAGE, two MASK - and here's the gotcha: only the two slots that match your connected inputs are real. If you feed image_1 and image_2, outputs 1 and 2 are your matched images and the mask outputs are random placeholder noise. Wire a placeholder into something and you'll get pure garbage downstream with no obvious cause. Just ignore the unused slots. It's also strictly a two-input node: it only reads the first two connected inputs, and if you wire three or four the node can error out, so don't.

Installing it

ComfyUI Manager is the easy path - search "Size Matcher" or size-match-compositing-nodes and hit install, then restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/christian-byrne/size-match-compositing-nodes
# then restart ComfyUI

The only real dependency is TensorImgUtils, a small PyPI package by the same author that reshapes tensors between formats. Manager handles it; if you install manually and get an import error, pip install TensorImgUtils fixes it. Python 3.10+ is all it asks, and there are no model files anywhere in this pack.

Things that bite

  • Wrong method, wrong crop. Pick cover_crop_center when you meant fit_center and you'll wonder where the edges of your image went. If something got clipped, switch to a fit/pad method; if it came out distorted, you grabbed fill.
  • The placeholder outputs. Already covered, but it's the #1 confusing thing about this node, so: don't wire unused outputs.
  • It won't upscale quality. This is geometry, not super-resolution - fill on a tiny mask stretched to a huge canvas just gives you a blurry stretched mask. Match sizes with the geometry you need, then upscale separately if quality matters.

It's not a flashy node. It's the kind you install once, forget about, and then feel mildly annoyed at every workflow that doesn't have it.

Categoryimage

Inputs (5)

NameTypeDefaultDescription
methodCOMBO7 options: cover_crop_center, cover_crop, center_dont_resize, fill, fit_center, crop_larger_center, +1
image_1optIMAGE
image_2optIMAGE
mask_1optMASK
mask_2optMASK

Outputs (4)

NameTypeDescription
IMAGEIMAGE
IMAGEIMAGE
MASKMASK
MASKMASK