Nodes/comfyui_met_suite/Image Resize Keep Ratio
ComfyUI Node

Image Resize Keep Ratio

Resize an Image Without Squashing It — and Get the Numbers Back

By metncelik·Created 2 years ago·Updated about a year ago· 2
Image Resize Keep Ratio
  • image
  • resized_image
  • new_width
  • new_height
width512
height512

Core ComfyUI can resize an image to exactly 512×512. That's also how you end up with a squashed face, because forcing an arbitrary image into a fixed square rarely keeps its proportions. Image Resize Keep Ratio is the version that doesn't do that: it fits the image inside your target width×height, preserving the aspect ratio, and - here's the part that makes it worth having - hands back the actual new_width and new_height as INTs so downstream nodes can agree on what just happened.

Mechanically it's boring, in a good way. It reads the source image's aspect ratio, works out the largest size that fits inside the target box, and resizes with Pillow's default bicubic resampling. The output is never padded: a 16:9 image asked to fit in 512×512 comes back 512×288, not 512×512 with bars. If you genuinely need exact dimensions with a fill, you pair this with a pad or canvas node afterward - this one only ever shrinks to fit.

The new_width/new_height outputs are the real reason to reach for it over the core ImageScale node (which already has a keep-proportion toggle - honest talk: if you're happy with ImageScale, you may not need this node at all). What core doesn't give you is the resulting dimensions as wired numbers. Feed them into a canvas creator, a latent, or a second resize downstream and everything stays in lockstep without you doing ratio math in your head. It also turns "resize this whole batch to a common box" into a one-node operation, which matters when you're pre-processing a folder of reference images for a vision-language model or an inpaint chain.

Inputs: image, plus width and height, both default 512. There's no keep-ratio toggle and no 0-means-auto behavior here the way the suite's BBOX Resize has - this node is always ratio-preserving, so keep both inputs positive. Set width to 0 and you'll be asking Pillow to resize to a zero-pixel dimension, which just errors. Outputs: resized_image, new_width, new_height.

Install matches its siblings in this pack. ComfyUI Manager → search comfyui_met_suite → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/metncelik/comfyui_met_suite

then restart ComfyUI. Only dependency is Pillow, which you already have - no models, no keys.

The one trap to remember: output size ≠ the box you typed. If you need a guarantee that the result is exactly 512×512, this isn't the node for that job on its own. It's the node for "keep my image looking like my image," and for knowing the numbers afterward.

CategoryMET SUITE/image

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
widthINT512
heightINT512

Outputs (3)

NameTypeDescription
resized_imageIMAGE
new_widthINT
new_heightINT