Match Dimensions (mtb)
Resize one image to fit another, aspect ratio intact
- source
- reference
- image
- new_width
- new_height
The description says it directly: "Match images dimensions along the given axis, preserving aspect ratio." You give it two images - a source you want to resize, and a reference you want it sized to match - and pick whether you're matching on height or width. The source gets scaled so that dimension lines up with the reference, while its own aspect ratio stays intact (so the other dimension moves too, proportionally, rather than staying fixed).
Why you'd reach for it
This comes up any time you're compositing two images that started life at different sizes and need at least one dimension to line up before anything downstream - a background plate and a subject cutout, two frames from different sources you're about to blend, or prepping a pair of images for a node that expects matching dimensions (some compositing and ControlNet setups are picky about this). Rather than eyeballing pixel values and typing them into a resize node by hand, you point this at the reference image and let it work out the math.
Inputs and outputs that matter
source- the image getting resized.reference- the image whose size you're matching against.match(defaultheight) - which axis to match:heightorwidth. Pickheightwhen you want both images to sit at the same vertical size (common for side-by-side or stacked comparisons),widthwhen horizontal alignment matters more.
Three outputs: image (the resized source), plus new_width and new_height as plain INTs - the actual dimensions it landed on, useful if a downstream node needs the numbers explicitly rather than just the resized image itself.
Installing it
- ComfyUI Manager - search "MTB Nodes", install, restart.
- Manual -
cd ComfyUI/custom_nodes && git clone https://github.com/melMass/comfy_mtb, restart. A manual clone needspip install -r requirements.txtrun inside thecomfy_mtbfolder first.
No models attached - this is straightforward tensor resizing.
Common issues & troubleshooting
Result isn't the size you expected. Remember only one axis is explicitly matched - the other one follows proportionally from the source's own aspect ratio, not the reference's. If source and reference have very different aspect ratios, matching on height can leave you with a width that's much wider or narrower than the reference's actual width. If you need both dimensions to match exactly regardless of aspect ratio, this isn't the node for that (you'd want a crop or a stretch-resize instead).
Composite still looks misaligned after matching. Matching one dimension gets sizes compatible, but doesn't handle position - you'll likely still need a compositing node to actually place the resized source where you want it relative to the reference.
Some mtb nodes fail to load on startup. Standard for this pack - check the console for [comfy_mtb] STATUS and http://127.0.0.1:8188/mtb for what didn't load. This node has no optional dependencies, so it's essentially never the one missing.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| source | IMAGE | — | |
| reference | IMAGE | — | |
| match | COMBO | height | 2 options: height, width |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| new_width | INT | — |
| new_height | INT | — |