Qwen Image 2.1 PE Canvas T8
How your Qwen Image 2.1 render gets its actual size
- pe_result
- width
- height
- latent
- ratio_source
The unglamorous node nobody explains
When you ask an LLM to rewrite your prompt, it doesn't just return nicer words - the official Qwen Image 2.1 templates also make it commit to a shape. The model picks a wh_ratio like 16:9, or it points at one of your reference images and says "follow this one" (<image2>). Nothing in ComfyUI knows what to do with that, and a prompt written for a 16:9 frame in a 1:1 canvas is a fight you lose slowly.
PE Canvas T8 is the translator. It reads the structured packet from PE Rewrite T8, turns the ratio into actual pixels inside a budget you pick, and emits an empty latent at exactly the shape Qwen Image 2.1's VAE expects. Three knobs, four outputs, and it's the difference between "the model obeys my prompt" and "the model obeys my prompt but everything is oddly cropped."
The mechanism, since it's short
Two inputs decide everything, and resolution is the one people misread: it is a pixel budget, not a side length. resolution=1024 means roughly 1024² ≈ 1.05 megapixels of canvas, whatever the aspect ratio. So 16:9 at 1024 comes out around 1360×768, and 9:16 gives you the same numbers swapped. The tooltip the author wrote says exactly this, and it's the difference between expecting a 1024-wide image and getting a 768-wide one.
If the rewritten packet says "follow <imageN>", Canvas takes that reference image's original dimensions - the downsized vision copy the rewrite node used doesn't leak in here - and derives the ratio from them. With follow_input_size on (the default), it keeps the size, scaled into the budget and capped at a 4096-pixel longest side. Turn follow_input_size off and you keep only the ratio, with the budget recomputed fresh - that's what you want when your reference is a 4000 px photo and you'd rather not render a 1360 px image just because the crop matched.
Everything then gets floored onto a 16-pixel grid, and if a reference is absurdly long and thin - the kind of 8000×16 strip you get from a screenshot - the node raises "aspect ratio is too extreme for the selected canvas budget" instead of quietly shipping a 16-pixel-wide latent. The latent itself is torch.zeros([1, 64, height/16, width/16]) on Comfy's intermediate device: 64 channels at 16× downsampling, the shape the author verified against the current Qwen Image 2.1 nodes. Don't try to feed it to anything expecting four channels.
Inputs and outputs
- pe_result - required, and it only comes from PE Rewrite T8. There is no way to type a ratio in by hand. If you just want a fixed canvas and no rewriting, this node is the wrong tool.
- resolution - INT, 256 to 4096, step 32, default 1024. The pixel budget described above.
- follow_input_size - BOOLEAN, default on. Keep the reference image's actual dimensions (scaled into budget) rather than only its aspect ratio.
Four outputs: width and height (INTs), latent (LATENT), and ratio_source (STRING).
The latent goes to the sampler - that's the whole point. The width and height mostly exist so you can resize your reference images to match the canvas before an edit, or just see what the model decided. ratio_source is the honest one: it tells you what actually won, either the ratio string (16:9) or the port reference (<image2>), which is exactly what you want on a PreviewAny when a render comes back at a size you didn't expect. Note that if you set aspect_ratio explicitly in the Rewrite node, it overrides the model's own pick and clears the "follow an image" rule, so the ratio flowing into Canvas is yours - the model's original suggestion survives in the rewrite diagnostics if you're curious.
Wiring it up
The author's full example workflow is the shape to copy: QwenPERewriteT8.rewritten_prompt → TextEncodeQwenImage21, QwenPECanvasT8.latent → KSampler.latent_image, decode, save. The important detail is that if you're editing, the reference images have to be connected to both the Rewrite node and the encoder, in the same port order - the rewrite prompt talks about <image1> and <image2>, and the encoder needs to see the same two images in that order or you've just written fan fiction.
Installing it
Same pack, same restart, same downloads - nothing extra for Canvas. Manager search qwen-image-prompt-rewrite-t8, or:
cd ComfyUI/custom_nodes
git clone https://github.com/T8mars/Comfyui-Qwen-Image-Prompt-Rewrite-T8.git
Canvas can't do anything without the Rewrite node feeding it, so install the pack once and set both up together.
Where it goes wrong
"Required input is missing: pe_result." You wired the string output instead of the structured one. rewritten_prompt is a STRING, pe_result is a PE_RESULT; the types don't convert, and rerouting around it won't work.
Your render is smaller than you asked for. You set resolution expecting a long edge and got a pixel budget instead. Raise it, or accept that 1024 on a 21:9 canvas is a 1552×656 render.
The aspect ratio silently changed between runs. ratio_follow is the model's decision, not a setting, so a rewrite that picked <image1> last time may pick a plain ratio this time. seed on the Rewrite node is your lever for reproducibility; ratio_source is how you confirm what happened.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| pe_result | PE_RESULT | — | |
| resolution | INT | 1024256–4096 | 画布像素预算为 resolution²;跟随原图尺寸时,大图会等比缩至预算内。 |
| follow_input_size | BOOLEAN | true | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| latent | LATENT | — |
| ratio_source | STRING | — |