QwenImage ratio
Pick a supported aspect ratio and resize straight to it
- images
- masks
- option
- images
- masks
- width
- height
Modern text-to-image models, Qwen-Image included, are trained on a fixed set of aspect ratios and resolution buckets, not arbitrary dimensions. Feed one an odd width and height and you're not getting a clean image at your requested size for free - you're asking it to work outside what it actually learned, and results get worse the further you drift. This node sidesteps the guesswork: pick one of Qwen-Image's supported ratios from a dropdown, and get back exactly the width and height to build your latent at, plus an optional resize of an existing image or mask into that shape.
It's part of ComfyUI-WJNodes, a personal utility pack - the author publishes only as 807502278 on GitHub, and this node is a good example of the kind of thing that pack contains: small, specific, and clearly built to solve a real annoyance from actually using these models.
Qwen-Image itself is Alibaba's Apache 2.0 image family - a 20B parameter model whose text-rendering and prompt adherence made its Edit line a default for open instruction-based editing. Getting your input dimensions aligned to what it expects matters more with a model this size, where a mismatched resolution costs real generation time to find out it didn't help.
Inputs and outputs that matter
- ratio - a dropdown of seven presets: 1:1, 2:3, 3:2, 4:3, 3:4, 16:9, and 9:16, defaulting to 1:1. This covers the standard square, portrait, and landscape shapes you'd actually reach for.
- images (optional) - if you supply an existing image, this node resizes it to match the selected ratio, rather than only telling you what the ratio would be.
- masks (optional) - same idea, applied to a mask alongside the image.
- option (optional) - additional settings from a companion node, for finer control over how the resize behaves.
Four outputs: images and masks come back resized (if you supplied them), and width / height give you the resolved pixel dimensions for the chosen ratio - wire those straight into an Empty Latent Image node for a clean text-to-image generation, or into a resize node if you're preparing an image for an img2img or edit pass.
Why this beats typing dimensions by hand
The alternative to this node is memorizing (or looking up) which exact width/height pairs a given model was actually trained on, then typing them into a latent node every time you want a different aspect ratio. That's error-prone and easy to get subtly wrong - a ratio that's close to 16:9 but not quite the resolution bucket the model expects. This node collapses that into one dropdown, and if you're also resizing an existing image or mask to match, it does that step in the same node instead of a separate resize + crop combination.
Installing it
ComfyUI Manager: search "ComfyUI-WJNodes." Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-WJNodes.git
Restart ComfyUI afterward. No models or extra dependencies needed for this node.
Where to be careful
This node hard-codes its ratio list around Qwen-Image specifically - if you're working with a different model family, the exact dimensions this resolves to may not be the buckets that model actually prefers, even if the ratio label looks the same. The pack also ships a more generic sibling, ratio_selector, with the same seven ratios but no built-in resize and no Qwen-specific framing - reach for that one instead if you need the ratio value wired into something other than this node's own resize behavior, or if you're not working with Qwen-Image at all.
Beyond that, there's nothing unusual to watch for - it's a small, self-contained utility, and there's no public discussion of this specific node to cross-reference if something looks off, so the README and the node's own defaults are the whole reference.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| ratio | COMBO | 1:1 | 7 options: 1:1, 2:3, 3:2, 4:3, 3:4, 16:9, +1 |
| imagesopt | IMAGE | — | |
| masksopt | MASK | — | |
| optionopt | SO | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| masks | MASK | — |
| width | INT | — |
| height | INT | — |