Guess Resolution By Ratio
The lazy way to snap any image size to a model-friendly bucket
- width
- height
Every ComfyUI regular has had this moment: your image is 1347×903, the empty latent wants something nice and divisible by 64, and you're doing math in your head to figure out the closest "safe" resolution. Guess Resolution By Ratio is that mental math, packaged as a node. Give it any width and height, and it snaps the dimensions to the nearest standard aspect-ratio bucket, rounded to a multiple of 64.
Why does 64 matter? Diffusion models do their work in a latent space that's an 8× downscale of the image, and the internal patch sizes land on 8-pixel boundaries in latent space - which is 64 pixels in image space. Sizes that aren't multiples of 64 either get silently padded or produce subtly wrong outputs. This node exists so you never have to think about that again.
How it works
The node takes your input width and height, works out the aspect ratio, and compares it against an internal table of common buckets - 1:1 at 1024×1024, 9:16 at 720×1280, 2:3 at 768×1152, 3:4 at 768×1024, and friends. It picks the entry whose ratio is closest to yours, rounds both dimensions to the nearest multiple of 64, and - the nice touch - preserves your original orientation. Feed it a portrait image and you get a portrait bucket back, never a flipped one.
The output is two plain INTs (width and height), which means you can wire this into any node that takes dimensions: an Empty Latent Image, an image resize, a latent upscale, whatever. That's the real superpower - it's a universal "make this size sane" adapter.
The inputs that matter
Just two:
width- your starting width (64–8192, default 1024).height- your starting height, same range.
There's nothing else to configure, which is the whole point. One input pair in, one snapped pair out.
Where it earns its keep
The classic setup is piping the output of an image loader into a latent: load a reference image, let this node figure out the safe generation size, and feed the result into an Empty Latent or a resize node ahead of img2img. It's also handy when you're building shared workflows - someone drops a 1347×903 image in, and the graph quietly normalizes it to a sensible bucket instead of trying to generate at a weird native size. If you're hand-building a workflow, it saves you from the "closest multiple of 64" mental math table that everyone eventually memorizes and then forgets.
Installing
It ships in Sage Utils, so it's the pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/arcum42/ComfyUI_SageUtils.git
cd ComfyUI_SageUtils && pip install -r requirements.txt
Restart ComfyUI afterwards - or find "Sage Utils" in ComfyUI Manager. No models, no dependencies beyond the pack itself.
The honest caveat
It guesses by ratio, not by pixel count. A 2048×2048 square image and a 768×768 square both snap to the 1024×1024 bucket, because that's the table's 1:1 entry. If you were trying to upscale to 2048, this isn't the node for that - it's a ratio normalizer, not a scaler. Keep that in mind and it'll never surprise you. For everything else, it's the most low-effort quality-of-life node in the pack.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 102464–8192 | The input width. |
| height | INT | 102464–8192 | The input height. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| width | INT | The guessed width. |
| height | INT | The guessed height. |