π§ Image Size Calculator
Compute exact generation dimensions for any aspect ratio, every time
- width
- height
- aspect_w
- aspect_h
"Just set the width and height to a multiple of 64" is the most repeated piece of ComfyUI advice that people still get wrong by hand. This node is the fix: you give it an aspect ratio and a target size, it returns width and height already rounded to a multiple you choose. No mental arithmetic, no accidentally generating 1021Γ579 because you fat-fingered it.
It's part of the π§ SuperNodes pack by SuperCC, and in a normal workflow it's the second half of the aspect-ratio chain: Get Aspect Ratio snaps a source size to a clean ratio, this node turns that ratio into real pixel dimensions, and the ints feed straight into Empty Latent Image.
How it works
aspect_w and aspect_h define the ratio (16 and 9 for 16:9, tooltips say so). Then the mode combo decides what your size input means:
- max_size - the longer side becomes
size. So 16:9 withsize: 1024gives you 1024Γ576. - min_size - the shorter side becomes
size. Same ratio,size: 1024gives 1820Γ1024. - megapixels - ignore
size, target a total pixel budget via themegapixelsfloat instead. Handy when you want "about a 1MP image" without caring which side is longer.
Either way, both dimensions are rounded to the nearest multiple_of (default 16, but 64 or 128 are the values you'll actually want for latent friendliness), and the result is clamped so it never comes back smaller than one multiple_of.
Outputs are width, height, plus a passthrough aspect_w/aspect_h so you can chain several calculators or a display node off one ratio without re-deriving it.
When you'd reach for it
- Standardizing output size across a batch of images with different source ratios.
- Building a workflow where the resolution is computed from a source image, so you never hardcode dimensions.
- Target-megapixel generation - a lot of newer models (and upscalers like SeedVR2) behave differently depending on total pixel count, and this lets you lock that number.
Install
ComfyUI Manager, search "ComfyUI-SuperNodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/sonnybox/ComfyUI-SuperNodes
Restart ComfyUI. No model downloads. The pack's only extra dependency is matplotlib, and that's for the Sigmas Graph node, not this one. One thing to know: this pack uses ComfyUI's newer extension API, so a stale ComfyUI install simply won't load any of it - keep ComfyUI updated.
Gotchas
- Rounding to a multiple is exact, but "nearest multiple" can push a target a hair off - a 1024 target on 16:9 with
multiple_of: 64lands on 1024Γ576 anyway, but 1.85:1 with a smallmultiple_ofcan drift. Setmultiple_ofto 16 only if you truly need the flexibility; 64 keeps latent math clean. sizeis interpreted differently by mode, and the default mode ismax_size. If you switch tomegapixelsand leavesizeset, nothing bad happens -sizeis just ignored. Don't assume a hidden interaction.- It computes, it doesn't crop or pad. Feeding the result to a latent and getting letterboxing is a downstream problem, not this node's.
This is one of those boring utility nodes you stop noticing after a week - which is the whole point. It removes a class of typos, and typos are what you'll spend an hour chasing otherwise.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| aspect_w | INT | 11β1024 | The width ratio of the desired aspect ratio (e.g., 16 for 16:9). |
| aspect_h | INT | 11β1024 | The height ratio of the desired aspect ratio (e.g., 9 for 16:9). |
| mode | COMBO | Determines if the size applies to max/min dimension, or if target is total megapixels. | |
| size | INT | 10241β32768 | The target length for the dimension specified by dimension mode. |
| megapixels | FLOAT | 1.000.01β1024 | The target total megapixels when mode is 'megapixels'. |
| multiple_of | INT | 161β1024 | The final dimensions will be rounded to the nearest multiple of this value. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| width | INT | The calculated width. |
| height | INT | The calculated height. |
| aspect_w | INT | Passthrough width aspect. |
| aspect_h | INT | Passthrough height aspect. |