Nodes/ComfyUI-keitNodes/AspectRatioResolutionFinder
ComfyUI Node

AspectRatioResolutionFinder

AspectRatioResolutionFinder

By keit0728·Created about a year ago·Updated about a year ago· 3
AspectRatioResolutionFinder
  • image
  • width
  • height
height_preset720p

This node does almost nothing, and that's the point. Feed it any image and it returns two integers - a width and a height that keep that image's aspect ratio at a height you pick. No resize, no VAE, no heavy lifting. You use it when you want to plan a resolution before anything touches a model.

Why would you want that? Standardizing a batch. Say you've got a folder of reference images at all sorts of shapes and you're building a workflow that generates every one at the same height (1080p, say) while preserving each one's own proportions. That's the classic "hires fix, but consistent" pipeline: the actual resize happens later, in a proper resampler or latent, and this node just tells you what dimensions to aim for. Because the calculation is trivial and happens entirely in Python, it's instant, and it doubles as a handy "show me this image's aspect ratio" inspector when you're debugging why a workflow keeps producing distorted output.

How it works

The mechanism is embarrassingly simple - which is why it's reliable. It reads the input tensor's shape ([batch, height, width, channels]), computes width / height, then does:

target_width = round(target_height * aspect_ratio)

That's the whole trick. No rounding to nice numbers, no cropping, no pixel limits. height_preset is the one input you actually touch: 13 options from 144p up to 2160p, defaulting to 720p. Pick the height, get back width and height as INT outputs.

Wiring it

Both outputs are plain integers, so they slot into anything that takes a resolution - latent resizes, empty latent dimensions, other custom nodes' width/height ports. A typical graph: Load Image → AspectRatioResolutionFinder → (width, height) into a Latent or a KSampler's conditioning prep.

The trap

The values it hands you are exact. If you're feeding this into a video pipeline (Wan, LTX), raw rounded-to-the-pixel dimensions will often not be multiples of 16, and the 3D VAE will either reject them or give you a tile seam. For image work you mostly don't care; for video, pair this with the same pack's PixelLimitResizer or round the outputs yourself. That distinction - "planning" node vs "actually safe to feed a VAE" node - is the whole difference between this and its siblings in the pack.

Installing

It ships in ComfyUI-keitNodes:

cd ComfyUI/custom_nodes
git clone https://github.com/keit0728/ComfyUI-keitNodes
cd ComfyUI-keitNodes
pip install -r requirements.txt

Then restart ComfyUI, or just search "ComfyUI-keitNodes" in the Manager and let it handle the rest. No models, no GPU, no extra downloads for this one - it's pure math.

Where people get burned: nothing here is heavy, so the only real failure is expecting it to resize. It won't. It calculates. If you need the image resized too, reach for PixelLimitResizer - that's the one from this pack that actually touches pixels.

CategorykeitNodes

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
height_presetCOMBO720p13 options: 144p, 240p, 360p, 480p, 540p, 576p, +7

Outputs (2)

NameTypeDescription
widthINT
heightINT