Size Match Images/Masks
The Node That Ends the Resize-Chain Spaghetti
- image_1
- image_2
- mask_1
- mask_2
- IMAGE
- IMAGE
- MASK
- MASK
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_centerandcover_cropscale to cover then crop the overflow (center vs. top-left),fit_centerscales to fit inside and pads the leftover space,center_dont_resizepads without scaling at all, andfilljust stretches - yes, it distorts the aspect ratio. - Crop the larger one down to match the smaller:
crop_larger_centerandcrop_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_centerwhen you meantfit_centerand 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 grabbedfill. - 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 -
fillon 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.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| method | COMBO | 7 options: cover_crop_center, cover_crop, center_dont_resize, fill, fit_center, crop_larger_center, +1 | |
| image_1opt | IMAGE | — | |
| image_2opt | IMAGE | — | |
| mask_1opt | MASK | — | |
| mask_2opt | MASK | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| MASK | MASK | — |