Nougan Match Image Size π
Make one image match another's dimensions β without the resize math
- input
- reference_image
- image
- mask
- width
- height
Compositing, img2img, and control-net work all share one chore: get image B to match image A's dimensions, or everything downstream complains about shape mismatches. NouganMatchImageSize is that chore as a node - resize an IMAGE or MASK toward a reference image's size (or explicit width/height), with eight resize modes, and get the image, mask, and computed dimensions back.
How it works
You give it an input (image or mask) and a target: either wire a reference_image and read its size, or set explicit width/height (which override the reference). Then resize_type decides the geometry. The modes split into two families:
- Exact-size:
scale dimensions(stretch or center-crop to exact WΓH),fill (crop)(cover WΓH, center-cropped). - Aspect-preserving:
fit within,pad to(fit inside WΓH, padded with a hexpad_color),shortest side,longest side,fit width,fit height.
All computed dimensions can be snapped to a multiple via round_to - set 32 and your output is always divisible by 32, which video-model and some DiT pipelines require. scale_method picks the resampler (default lanczos). It's ComfyUI's common_upscale under the hood, so the quality behavior matches what you already know from UpscaleImage.
The inputs that matter
input- the image or mask to resize.resize_type- the geometry mode.scale dimensionsis the default and the one you'll mostly want.reference_image- wire the image whose size you're matching.width/height- explicit targets; 0 means "use the reference."round_to- snap dims to a multiple (1 = off, 32 = the usual).crop- used byscale dimensions:centerordisabled.pad_color- hex color used bypad to.
Outputs: image and mask (both resized), plus width and height ints you can feed into an empty-latent or resolution-picker node.
Installing
Manager search Nougan, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Winnougan/Nougan_Nodes
# restart ComfyUI
No dependencies beyond the pack and ComfyUI itself.
Where people get burned
The one hard error is running it with no target at all - no reference and width/height left at 0 - which raises "No target size - connect a reference_image or set explicit width/height." That's a helpful message; trust it. The subtler gotcha is scale dimensions with crop disabled: it stretches rather than letterboxing, so aspect ratios get distorted in ways that are easy to miss if you're only looking at the output size. If you need to preserve aspect and fill the frame, that's pad to or fill (crop), not scale-dimensions. For "make this match that," it's the one-liner the task deserves.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| input | IMAGE,MASK | β | |
| resize_type | COMBO | scale dimensions | 8 options: scale dimensions, fit within, fill (crop), pad to, shortest side, longest side, +2 |
| scale_method | COMBO | lanczos | 5 options: nearest-exact, bilinear, area, bicubic, lanczos |
| reference_imageopt | IMAGE,MASK | β | |
| widthopt | INT | 00β16384 | 0 = use reference width |
| heightopt | INT | 00β16384 | 0 = use reference height |
| cropopt | COMBO | center | used by 'scale dimensions' |
| pad_coloropt | STRING | #000000 | hex color used by 'pad to' |
| round_toopt | INT | 11β128 | round computed dims to a multiple (e.g. 32) |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | β |
| mask | MASK | β |
| width | INT | β |
| height | INT | β |