Nodes//Nougan Match Image Size πŸ“
ComfyUI Node

Nougan Match Image Size πŸ“

Make one image match another's dimensions β€” without the resize math

By WinnouganΒ·Created 2 months agoΒ·Updated about a month agoΒ· 4
Nougan Match Image Size πŸ“
  • input
  • reference_image
  • image
  • mask
  • width
  • height
β—„resize_typescale dimensionsβ–Ί
β—„scale_methodlanczosβ–Ί
β—„width0β–Ί
β—„height0β–Ί
β—„cropcenterβ–Ί
β—„pad_color#000000β–Ί
β—„round_to1β–Ί

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 hex pad_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 dimensions is 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 by scale dimensions: center or disabled.
  • pad_color - hex color used by pad 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.

CategoryNougan/image

Inputs (9)

NameTypeDefaultDescription
inputIMAGE,MASKβ€”
resize_typeCOMBOscale dimensions8 options: scale dimensions, fit within, fill (crop), pad to, shortest side, longest side, +2
scale_methodCOMBOlanczos5 options: nearest-exact, bilinear, area, bicubic, lanczos
reference_imageoptIMAGE,MASKβ€”
widthoptINT00–163840 = use reference width
heightoptINT00–163840 = use reference height
cropoptCOMBOcenterused by 'scale dimensions'
pad_coloroptSTRING#000000hex color used by 'pad to'
round_tooptINT11–128round computed dims to a multiple (e.g. 32)

Outputs (4)

NameTypeDescription
imageIMAGEβ€”
maskMASKβ€”
widthINTβ€”
heightINTβ€”