EmAySee Aspect Ratio Calculator
One number in, two out — the aspect-ratio calculator that keeps things proportional
- image
- output_width
- output_height
ComfyUI will happily upscale an image into the wrong shape if you hand it bad numbers, and "bad numbers" usually means a width that doesn't match the image's actual aspect ratio. EmAySee Calculate Aspect Ratio is a three-input sanity node: feed it an image and a target height, and it returns the width that keeps the original proportions.
That's the whole job - and it's genuinely the right job for the upscaling half of a workflow. Say you have a 1536×1024 image and you want to feed it to an upscaler at a specific height. You type 1024 as the output height, and the node computes width = height * (original_width / original_height) - so you get back a width that preserves the frame instead of stretching it. It keeps image or latent pipelines honest when the downstream node needs explicit dimensions.
How it works
The mechanism is a single division, visible in py/EmAySee_CalculateAspectRatio.py. It reads the image's shape, computes the aspect ratio, and multiplies by your target height:
ratio = original_width / original_height
output_width = int(output_height * ratio)
The height you provide is returned verbatim; only the width is computed. It's a proportional scaler, not a resizer - it produces dimensions for you to feed elsewhere, and produces no image itself.
The inputs that matter
- image - the reference image whose aspect ratio you want to preserve.
- output_height - the target height, default 512, minimum 1.
Outputs are output_width and output_height, both INT.
Install
Ships in the EmAySee pack:
cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
Restart ComfyUI (or Manager → "ComfyUI_EmAySee_CustomNodes"). Category: EmAySee_Utils.
Gotchas
The trap worth knowing: the result is not rounded to a model-friendly multiple of 8 (or 16, or 64 depending on your model). Your 1536×1024 image scaled to a target height of 1024 gives you width 1536 - clean - but many arbitrary inputs won't come out so tidy, and feeding a non-multiple-of-8 dimension into a latent or a sampler can cause errors or subtle artifacts. Round the output yourself with a math node (int(w / 8) * 8) or use a resolution-aligning node afterward. And the standing pack caveat applies: unsupported hobbyware, no guarantees - trivial math, but verify the output before you pipe it into an expensive generation.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| output_height | INT | 512 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| output_width | INT | — |
| output_height | INT | — |