Wan Get Max Image Resolution By Aspect Ratio
The biggest latent that model will accept
- image
- Width
- Height
Wan models have hard resolution ceilings: a maximum side length and a maximum total pixel budget, and going past either one produces artifacts or a sampler that refuses to run. The annoying part is that the limit depends on your aspect ratio - a 16:9 image can afford more pixels than a square at the same long side. This node does the "how big can I actually go" math for you: you give it a Wan model type and your input image, and it returns the largest width and height that respect the model's constraints while keeping your aspect ratio.
Feed the outputs into your Empty Latent or sampler resolution and you're always right at the edge of what the model can handle - which is where Wan quality lives. Under-shoot and you leave quality on the table; overshoot and you're in artifact territory.
How it works
The constraints come straight from the code's per-model table:
- Wan 480p - max side 832, max pixels 832×480 (≈400K).
- Wan 720p - max side 1280, max pixels 1280×720 (≈921K).
- Wan 2.2 - same ceilings as 720p: 1280 side, 1280×720 pixels.
The algorithm is two steps: first scale the image so its longest side hits the model's max_side, keeping aspect ratio; then, if the resulting pixel count still exceeds the model's max_pixels, scale down by the square root of the overage until you're within budget. That second step is what makes it aspect-ratio-aware - a tall skinny image gets capped by the side limit first, a big square gets capped by the pixel budget.
The inputs that matter
model_type- the three-way dropdown: Wan 480p, Wan 720p, Wan 2.2.image- any IMAGE; only its dimensions are used, not the content.
Outputs: Width and Height, both INTs.
Installing it
Part of ComfyUI-Przewodo-Utils. ComfyUI Manager → search the pack, or:
cd ComfyUI/custom_nodes
git clone https://github.com/przewodo/ComfyUI-Przewodo-Utils.git
Restart. No extra dependencies - it's dimension math on a tensor shape.
Where people get tripped up
The honest caveat: the node doesn't round to VAE-friendly multiples. Wan's VAE compresses 4× per axis, and many Wan samplers expect width/height divisible by 16 (or at least by 8). This node can return, say, 1246×704 - right at the budget but not aligned to the VAE's tile grid. If your sampler chokes on a shape error, round the outputs down to the nearest 16 yourself (or through a math node) before feeding the sampler. "Maximum" here means maximum by pixel budget, not "guaranteed sampler-safe."
Also note the model table is a snapshot - Wan 2.2 is the last open-weight Wan (everything after 2.5 is API-only), and the 480p ceiling applies to the 2.1-era I2V models. If you're using a custom Wan build with different tolerances, trust the node's numbers less and your sampler's errors more.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model_type | COMBO | WAN model type that determines maximum resolution constraints and pixel limits for optimal processing | |
| image | IMAGE | Input image to analyze for calculating optimal width and height based on aspect ratio and model constraints |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| Width | INT | — |
| Height | INT | — |