Optimal Resolution
Let This Node Do the Model Math
- width
- height
Every model has a native resolution and a divisor it wants its latents rounded to. SD 1.5 wants 512. SDXL wants one of its handful of trained aspect ratios. Wan 2.2 wants specific 480p/720p pairs. Flux wants multiples of 16. If you're like me, you've got a sticky note (or a mental model) for this - and you still generate at 1920x1080 one time too many and get stretched anatomy. Optimal Resolution is a small node that just answers "what size should my latent be?" for a specific model and aspect ratio, and hands you the two integers.
It's not magic, and it won't fix your prompt. But it kills one of the most annoying recurring sources of bad images in ComfyUI - because generating off-native resolution is exactly how you get double heads, elongated bodies, and repeated patterns. That's the classic failure mode the community keeps rediscovering: someone feeds a 1024-native model a wildly wrong aspect ratio and wonders why the anatomy broke.
How it works
Under the hood this is a lookup table plus a calculator, and that's a compliment. The pack ships per-model JSON configs (in data/image/ and data/video/) that store three things: a base_resolution, a multiple_of divisor (8, 16, or 32 depending on the model), and a list of resolution modes.
When you pick a mode and aspect ratio, the backend does the arithmetic:
- "Fixed (exact)" - looks up the exact width/height pair the model card specifies. Pick Wan 2.2 14B + "16:9 (720p)" and you get 1280x704, which is 720p rounded to a multiple of 16.
- "Area: N² (x.xMP)" - takes the megapixel target, derives
height = sqrt(area / ratio)andwidth = height × ratio, then rounds both to the nearest multiple of the model's divisor and clamps the minimum to that divisor so you never get a 0-sized latent.
The frontend fetches the config from a /optimal_resolution/models endpoint and shows the computed "1280 x 704" right on the node, so you see the result before you ever run the workflow. Note this is a Comfy Nodes 1.0–era extension (it's built on the new ComfyNode API), so keep ComfyUI reasonably current; the on-node display is a Nodes 1.0 feature.
The inputs that matter
Four dropdowns, that's it:
- model_type - Image or Video, which just filters the model list.
- model - pick yours: SD 1.5, SDXL, Flux 1/2, Qwen Image, Z-Image, Ernie Image on the image side; Wan 2.2 14B/5B, SVD XT, LTX 2.3 on the video side.
- resolution - the mode. Only valid modes for the chosen model are shown, so the dropdown does a lot of the work for you.
- aspect_ratio - also filtered per model/mode. SVD XT, for instance, only offers 16:9.
Outputs are two INTs, width and height. Wire them straight into Empty Latent Image (or your video sampler's resolution inputs). Because the node outputs plain integers, you can also route them into a text field or use them to size other nodes.
Installing it
No Python dependencies, no model downloads - it's pure config + a bit of JS:
cd ComfyUI/custom_nodes
git clone https://github.com/caradat/comfyui-optimal-resolution.git
Restart ComfyUI and it shows up as Optimal Resolution under the image category. If you use ComfyUI Manager, just search "optimal resolution".
Gotchas
The biggest one is expectation management: this node knows the models the author shipped, not the whole universe. If your checkpoint isn't in the list, you add it - that's the whole design. Drop a JSON file into data/image/ or data/video/ with base_resolution, multiple_of, and resolution_options, and it appears in the dropdown. No Python touched.
Two other things worth knowing. First, if the calc hits an error the node falls back to 1024x1024 - so if you suddenly see a fixed 1024x1024, check the terminal for an [OptimalResolution] warning rather than assuming the aspect ratio changed. Second, treat the shipped numbers as sensible defaults from model docs, not divine truth; the divisor rounding guarantees VAE-friendly sizes, but "best" resolution is still a taste thing - the KB's notes on 2026 models (Z-Image happy at 1–2MP, Flux 2 Klein clean in a 1–2MP band) back up the configs.
Is it a must-install? No - a cheat sheet and a calculator app do the same job. But if you swap models constantly or share workflows with people who shouldn't need your mental model, it's a genuinely nice QoL node, and it's cheap: no deps, no downloads, instant answer.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| model_type | COMBO | 2 options: Image, Video | |
| model | COMBO | 12 options: Loading..., Z Image, Qwen Image, Flux 1, SDXL Base, Ernie Image, +6 | |
| resolution | COMBO | 17 options: Standard, Area: 512² (0.26MP), Area: 640² (0.41MP), Area: 768² (0.59MP), Area: 896² (0.80MP), Area: 1024² (1.0MP), +11 | |
| aspect_ratio | COMBO | 11 options: 1:1, 21:9, 9:21, 16:9, 9:16, 5:4, +5 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |