Flux Resolution Calc
Pick a Flux-friendly width and height by megapixels
- width
- height
- resolution
- preview
Flux doesn't think in SDXL's tidy 1024x1024 buckets. It thinks in megapixels, and it's happiest somewhere around one of them. So instead of memorizing "what's the 9:16 that Flux likes again?", you pick a megapixel count and an aspect ratio, and this node hands you a width and height that actually divide cleanly and land where the model wants to be. It's the most-reached-for node in the whole ControlAltAI pack, and honestly it's the one I'd install the pack for.
The reason it exists: Flux's base resolution is 1024x1024, and it'll happily push up to roughly 1536x1536 or ~2MP, but the good numbers aren't obvious once you leave a square. Guess wrong and you get stretched anatomy or a soft, mushy image. This node does the arithmetic so you don't eyeball it.
How it works
You choose a target megapixel (0.1 up to 2.5) and an aspect_ratio from a big list of named ratios - everything from 1:1 (Perfect Square) to tall vertical and wide cinematic. The node solves for the width and height that hit that pixel budget at that shape, then snaps both to a clean multiple so the VAE and the model don't choke on an odd dimension.
That snapping is the divisible_by setting, and it's the one people miss. Default is 64, and the author recommends 32 or 64 for Flux Dev. Drop it to 8 only when you want fine-grained control and you're on a fine-tune that tolerates it. Bigger divisor, safer dimensions; smaller divisor, more exact ratio.
There's also a custom_ratio toggle. Flip it on and type whatever you want into custom_aspect_ratio (something like 4:9) and it'll use that instead of the dropdown. Handy when your ratio isn't in the list.
The inputs and outputs that matter
megapixel- your size budget. 1.0 is the safe default; the README notes generations above 1MP can look slightly blurry, though 3k+ has been generated successfully on Flux Dev.aspect_ratio- the shape. Named entries so you're not doing fractions in your head.divisible_by- leave at 64 for Dev, 8 if you know what you're doing.
Outputs are width (INT), height (INT), a resolution string, and a preview image that's just a visual swatch of the ratio - don't wire the preview into anything, it's there so you can eyeball the shape. Send width and height straight into your empty latent node. For Flux that's the SD3 Empty Latent Image node, not the regular one.
How to install it
Easiest path is ComfyUI Manager: hit Install Custom Nodes, search ControlAltAI Nodes, install, restart. Prefer the terminal?
cd ComfyUI/custom_nodes
git clone https://github.com/gseth/ControlAltAI-Nodes
Then restart ComfyUI. This node is pure Python - no model downloads, no XFormers, nothing heavy. If you're on a managed cloud runner the pack may already be there; just search the node list.
Common issues
The classic one is dropping this width/height into a normal Empty Latent Image node and getting garbage. Flux wants the SD3 empty latent - the ControlAltAI Flux Sampler in this same pack expects that too. Wire it right and it just works.
The other thing: if you crank megapixel well past 1.0 and the result looks soft, that's Flux, not the node. It's telling you the truth about where the model gets blurry. Back off toward 1MP, or accept the softness and fix it with an upscale pass. And if you want the ratio to follow an existing image instead of a dropdown, the pack's Get Image Size & Ratio node feeds straight into the custom_aspect_ratio input.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| megapixel | COMBO | 1.0 | 25 options: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, +19 |
| aspect_ratio | COMBO | 1:1 (Perfect Square) | 23 options: 1:1 (Perfect Square), 2:3 (Classic Portrait), 3:4 (Golden Ratio), 3:5 (Elegant Vertical), 4:5 (Artistic Frame), 5:7 (Balanced Portrait), +17 |
| divisible_by | COMBO | 64 | 4 options: 8, 16, 32, 64 |
| custom_ratio | BOOLEAN | false | — |
| custom_aspect_ratioopt | STRING | 1:1 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| resolution | STRING | — |
| preview | IMAGE | — |