EmAySee Qwen Resolution Optimizer V2NS
That zoom you hate on Qwen Image Edit is a resolution problem
- image
- IMAGE
- width
- height
- total_pixels
- actual_mp
- recommended_mp
- resolution_text
If you've run Qwen Image Edit more than twice, you've seen it: you feed in a nice 1024x1024 and the edit comes back slightly zoomed, shifted, or cropped in a way you didn't ask for. The community pinned this on resolution a while back. Qwen Image Edit's VAE works in multiples of 16, and Qwen2.5-VL works in multiples of 14, so the safest input size is a multiple of both - and the least common multiple of 16 and 14 is 112. This node exists to hand you exactly that: an image resized and center-cropped to a target megapixel count, snapped to a 112px grid, with the math reported back so you can actually see what happened.
What it actually does
It's a one-shot resize + center-crop node. Give it an image and a target size in megapixels, and it works out a width and height that (a) keep your aspect ratio, (b) land as close to the target megapixel count as the grid allows, and (c) stay inside your min/max bounds. Then it center-crops the source to match the computed aspect ratio and bicubic-resizes it to the snapped dimensions.
The center crop is the thing to know about. If your source aspect ratio doesn't match the computed one exactly, it trims the sides or the top/bottom to make them match - so edges get cut. For Qwen editing that's usually fine, but don't use this on a composition where the borders matter.
The inputs that matter
- target_megapixels (default 1.0) - how big you want the output, in megapixels. 1 MP is the Qwen-Image sweet spot for a square; go up to 1.5 for detail-heavy edits.
- min_megapixels (0.1) and max_megapixels (1.5) - the clamp range. If your target can't be hit cleanly, it snaps inside this window instead.
- multiple_of (default 112) - the grid to snap to. Leave it at 112 for Qwen Image Edit; drop it for plain SDXL work where 64 or 8 is fine.
The outputs you'll actually use
- IMAGE - the prepared image, ready to feed a VAE encode.
- width and height - the final dimensions as ints, handy for wiring into an Empty Latent.
- total_pixels, actual_mp, recommended_mp - the bookkeeping, mostly for your own sanity.
- resolution_text - a
"1024x1024"style string. Slap it on a Text node in the corner and you'll never wonder what the sampler actually ran at.
Installing it
This is one node in the EmAySee utility pack. ComfyUI Manager: search ComfyUI_EmAySee_CustomNodes and install. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
# restart ComfyUI
No requirements.txt, no model downloads - it's pure torch math. It'll show up under EmAySee/Image in the add-node menu.
Gotchas
Watch the min/max interaction: if your source is huge and target is small, the clamp quietly wins, and you can get an output bigger than you asked for. That's by design - the node refuses to produce something the model can't handle. And remember the center crop: whatever's at the edges of your source is gone. If that breaks your edit, upscale or pad the source first instead.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| target_megapixels | FLOAT | 1.00.1–16 | — |
| min_megapixels | FLOAT | 0.100.05–1 | — |
| max_megapixels | FLOAT | 1.50.5–32 | — |
| multiple_of | INT | 1121–512 | — |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| width | INT | — |
| height | INT | — |
| total_pixels | INT | — |
| actual_mp | FLOAT | — |
| recommended_mp | FLOAT | — |
| resolution_text | STRING | — |