Auto Aspect Pad Comal
Why your Qwen-Edit output zooms in — and the pad node that stops it
- image
- mask
- image
- width
- height
- pad_info
- mask
You drop a source image into a Qwen-Image-Edit workflow, type "change her dress to blue," and the output comes back zoomed in, shifted a few pixels, or sitting on a subtly different canvas than what you fed it. That's not you misreading the model - it's the editor's best-known structural quirk, and Auto Aspect Pad (Comal) is a small, single-file node built to kill it at the source.
The problem it actually solves
Qwen-Image-Edit is the open instruction-editing default for good reason: 2509 and 2511 both re-emit the whole frame from a sentence, and they hold identity better than anything else you can run locally. But that re-emission is exactly where the trouble lives. The TextEncodeQwenImageEditPlus node ComfyUI uses force-rescales whatever image you hand it to roughly 1MP internally. If your actual latent canvas is a different size or aspect ratio, your reference latent and your output latent disagree, and the model panics into a zoom, an offset, or a subtle crop - the "unzooming" and offset complaints the community has chased since September 2025.
There are two community fixes, and this node is half of one. First: latent-reference chaining - VAE-encode your input and feed it to a ReferenceLatent node, leaving the text encoder's image/VAE inputs unplugged, so the encoder never gets a chance to force a rescale. Second: control the resolution you hand the model. Auto Aspect Pad automates that second half, and it's designed to sit right on top of the first.
How it works
The node does the padding for you, grounded in Qwen's own training geometry. It computes your source's aspect ratio, picks the closest of Qwen's nine official ratios (1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 21:9, 9:21) by comparing log-ratios, works out a target canvas from your megapixels setting, rounds it to your multiple grid, and letterboxes your image into that canvas - centered, with the geometry recorded in a pad_info bundle. Because your input now fills the exact canvas Qwen was trained on, the encoder's forced rescale has nothing to rescale: reference latent and output latent come out the same size, and the zoom can't happen.
The inputs that matter:
- aspect_ratio -
autopicks the closest official ratio; or force one of the nine explicitly. - megapixels - default 1.0, which matches Qwen's ~1MP internal target. Raise it for bigger edits.
- multiple - default 8, the Qwen VAE's alignment requirement. Min 8, goes up to 128.
- interpolation -
lanczosby default;bilinearif you'd rather trade a little crispness for speed. - mask (optional) - resized and padded the same way, so a mask stays aligned with the padded canvas.
Outputs: the padded image, the canvas width and height, the pad_info bundle, and the padded mask. width and height are exactly what you wire into an EmptyLatentImage.
Wiring it into a Qwen-Edit workflow
The README's example is the one worth copying: Load Image → Pad → width/height into EmptyLatentImage, and Pad's image into VAE Encode → ReferenceLatent. Do not connect the text encoder's VAE/image inputs - that unplugging is the whole latent-chaining trick. Then KSampler → VAE Decode → Auto Aspect Unpad, with pad_info wired straight across.
Install
ComfyUI Manager: search "Comal" or "Auto Aspect" and install. Or the manual way:
cd ComfyUI/custom_nodes
git clone https://github.com/comal0731/auto_aspect_ratio.git comal-auto
Restart ComfyUI and both nodes show up when you search "Comal." There's no requirements.txt, no model downloads, no heavy dependencies - it's pure torch/PIL, so nothing to babysit. MIT license. One heads-up: the README is in Korean, but the node UI itself is English.
Gotchas
Wire pad_info through untouched - it carries the original dimensions, the pad offsets, and the interpolation, and it's the whole contract between Pad and Unpad. If you're still chasing residual drift on a default (non-chained) Qwen workflow, the older community lever was keeping input resolution a multiple of 112; multiple is where you dial that in, and it goes up to 128. One honest caveat: lanczos runs through PIL on CPU, so a big batch resizes noticeably slower than the torch-backed bicubic/bilinear paths. And it's a young pack (v1.0.3, July 2026) with no long track record - but it's one readable file, the fix is simple, and the Qwen path it automates is well-trodden community ground. The author also lists Flux.2 Klein as a target; the Qwen side is the one with the receipts.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| aspect_ratio | COMBO | auto | 10 options: auto, 1:1, 16:9, 9:16, 4:3, 3:4, +4 |
| megapixels | FLOAT | 1.000.1–4 | — |
| multiple | INT | 88–128 | — |
| interpolation | COMBO | lanczos | 3 options: lanczos, bicubic, bilinear |
| maskopt | MASK | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| width | INT | — |
| height | INT | — |
| pad_info | PADINFO | — |
| mask | MASK | — |