Nodes/ComfyUI-qwen_preprocessor/Qwen Image Resize & Pad
ComfyUI Node

Qwen Image Resize & Pad

Your Qwen-Image-Edit isn't blurry — it's being resized for Flux

By GHOSTLXH·Created 7 months ago·Updated 7 months ago· 3
Qwen Image Resize & Pad
  • image
  • IMAGE
  • width
  • height
min_pixels1024
constraint_modeBalanced (56x) - Rec. for SD1.5/XL
upscale_methodbicubic

If your Qwen-Image-Edit outputs come back soft, stretched, or slightly off, the model isn't necessarily the problem - the image you fed it probably got resized for the wrong model. ComfyUI's default Qwen workflow reuses the preprocessing scale node that Flux Kontext uses, which snaps your image to the dimensions Flux likes. Qwen likes different ones. This tiny node from GHOSTLXH fixes exactly that one mismatch, and it's basically the only thing it does.

Why a Qwen-specific resizer exists at all

Qwen-Image-Edit is an instruction editor: you hand it a picture and a sentence, and it re-emits the whole frame with the change applied. Because it regenerates everything, it's picky about what goes in. Its image tokenizer expects both dimensions to land on a multiple of 28, and the community fix for its famous geometric-offset problem is even stricter - keep the input on a multiple of 112 and the output realigns. Meanwhile ComfyUI wants tensors on a multiple of 4/8/16/32. The stock workflow borrows Flux Kontext's scale node, which aligns to the wrong grid, and the result is a quieter version of the same offset and quality loss the community threads about. The author's README spells this out, and a reddit thread from launch week confirms the confusion: people genuinely can't tell why a "FluxKontext" node is wired into their Qwen graph.

How it works

The mechanism is honest and easy to follow. It reads the batch tensor, computes how much to scale so the short side reaches min_pixels (1024 by default; 0 means never force an upscale), then rounds width and height to the nearest multiple of your chosen alignment grid and resizes. If your image already fits the grid, it returns it untouched - no pointless round-trip.

The constraint_mode dropdown is where the author's math shows up. 56 is the least common multiple of 8 and 28, so Balanced (56x) - the default - satisfies both Qwen and ComfyUI at once. The other three are Strict Qwen (28x) (Qwen only, can trip ComfyUI's tensor checks), Safe (112x) (labeled for Video/Flux, but it's exactly the multiple the community offset fix wants), and Extreme (224x).

The three inputs that actually matter

  • min_pixels - the short side's floor after scaling. Bump it if your source images are tiny and you want the model to have more pixels to work with; set 0 if you only want grid alignment.
  • constraint_mode - pick your multiple. Start Balanced, go Safe (112x) if you see offset.
  • upscale_method - default is bicubic, but the README recommends lanczos, and it's the right call for photos. One honest caveat: the lanczos path round-trips through PIL on the CPU, while bicubic/bilinear/area/nearest run on the GPU via torch - so lanczos is slower on big batches, just better quality.

Outputs are the resized IMAGE (wire it into the Qwen image reference input) plus width and height as INTs, which is handy if you're keeping a VAE or latent side of the graph in sync.

Installing it

ComfyUI Manager → search "qwen_resizer" → install, or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/GHOSTLXH/qwen_resizer

then restart ComfyUI. No requirements.txt, no model downloads, no API key - it's pure torch/numpy/PIL on top of what ComfyUI already ships. This is as dependency-light as a custom node gets.

Where people trip up

The name says "Resize & Pad" but it doesn't pad - it only resizes. And if you're chasing offset, don't stay on the 56x default out of loyalty to it; the widely-shared fix for Qwen drift is the 112 grid, and that's one dropdown click away. It's a small, single-purpose tool from a small author, not a marquee node - but it's the kind of fix you stop noticing after a day, because you stop having to think about the grid at all.

CategoryQwen Image Edit

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
min_pixelsINT10240–8192若图像短边低于此像素值,将触发放大机制。设为0则不强制放大。
constraint_modeCOMBOBalanced (56x) - Rec. for SD1.5/XL选择尺寸对齐策略: - 28x: 仅满足Qwen。 - 56x: 同时满足Qwen和8的倍数(推荐)。
upscale_methodCOMBObicubic5 options: nearest-exact, bilinear, area, bicubic, lanczos

Outputs (3)

NameTypeDescription
IMAGEIMAGE
widthINT
heightINT