QwenLatentImage(NYJY)
The exact latent size Qwen-Image wants (no more guessing)
- LATENT
- width
- height
Qwen-Image, Alibaba's 20B Apache-2.0 image model, is a joy to generate with and a pain to size. Its native resolutions don't follow the 1024x1024 defaults you're used to from SDXL, and feeding it an off-grid size gets you an error or a noticeably worse image. QwenLatentImage exists so you never have to think about that again: it builds an empty latent at the exact resolutions the model actually wants.
It's a utility node in ComfyUI_NYJY (aidenli's pack, the same one wrapping the Volcengine/ByteDance APIs), and it's the Qwen-specific sibling of the pack's CustomLatentImage-NYJY node. If you've ever stared at a "resolution not supported" error from Qwen-Image, this is the fix.
How it works. Instead of free-form width/height, the node gives you a ratio dropdown with nine presets, each carrying Qwen-Image's native pixel bucket:
1:1 - 1328x1328,3:4 - 1104x1472,2:3 - 1056x1584,9:16 - 936x1664,9:21 - 864x2016, plus the mirrored landscape versions (4:3,3:2,16:9,21:9).
Notice the 1:1 default is 1328×1328, not 1024² - that's the model's actual sweet spot, and it's the sort of detail you'd otherwise have to dig out of the model card. Pick a ratio, and the node allocates a zeroed latent tensor with the right channel layout (4 channels, dimensions at height/8 × width/8), sized for the batch. It's the same pattern as the built-in EmptyLatentImage: a blank canvas you feed to a KSampler, which denoises it into the real image.
The inputs that matter. Three you'll touch:
ratio- pick the aspect ratio; this sets width/height from the preset.batch_size- how many latents to stack (1–100). Handy for batch generation.width_override/height_override- set both to non-zero to throw out the preset and use your own pixel size instead; leave them at 0 to trust the ratio.
The outputs. LATENT goes straight into a KSampler's latent input. The node also returns width and height as INTs, which is genuinely useful - wire them into nodes that need to know the output dimensions (like text-encoders or resizers) without hardcoding anything.
Install. It ships with the whole pack:
cd ComfyUI/custom_nodes
git clone https://github.com/aidenli/ComfyUI_NYJY
restart, then pip install -r requirements.txt (or ComfyUI Manager → "Install via Git URL" → https://github.com/aidenli/ComfyUI_NYJY). This node itself is dependency-free - just torch - but you'll want the pack's requirements anyway if you touch its other nodes.
When to reach for it. Whenever you're running a Qwen-Image checkpoint locally and you want the native resolution baked in instead of guessed at. It's a small node, but it turns "which pixel size does this model like?" from a research project into a dropdown.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| ratio | COMBO | 1:1 - 1328x1328 | 9 options: 1:1 - 1328x1328, 3:4 - 1104x1472, 2:3 - 1056x1584, 9:16 - 936x1664, 9:21 - 864x2016, 4:3 - 1472x1104, +3 |
| batch_size | INT | 11–100 | — |
| width_override | INT | 00–16384 | — |
| height_override | INT | 00–16384 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |
| width | INT | — |
| height | INT | — |