Nodes/ComfyUI_EmAySee_CustomNodes/EmAySee Qwen Pixel Aligner
ComfyUI Node

EmAySee Qwen Pixel Aligner

Resize to a Qwen-friendly resolution before the model sees your image

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee Qwen Pixel Aligner
  • image
  • IMAGE
  • width
  • height
  • resolution_text
longest_edge1232
alignment112

EmAySee Qwen Pixel Aligner resizes an image so its longest edge hits a target resolution and both dimensions land on a clean alignment multiple - then hands you the new width, height, and a WxH string. It's the "prepare your input for a Qwen-VL model" node, and the alignment detail is the whole reason it exists.

Qwen's vision-language models are picky about input sizes in a way that's easy to forget until you hit it. The community's crop-and-stitch workflow for Qwen-Image-Edit famously opens by warning that output comes back "slightly misaligned or blurred" even when the input is already a multiple of 112. When you're feeding an image to a local Qwen-VL captioning or editing model, the difference between "whatever resolution you had" and "a resolution that snaps to the model's expected grid" shows up as quality and alignment you don't have to fight afterward. This node exists to remove that variable.

How it works

The mechanism is simple and predictable. It computes a scale factor from your image's current longest edge to your chosen target, applies it to both dimensions to preserve aspect ratio, then snaps each dimension to the nearest multiple of your alignment value. The default alignment is 112 - the Qwen-VL token/patch grid - with 56 and 224 as alternatives for models that use a coarser or finer grid.

Two implementation details worth knowing:

  • The longest-edge targets go from 784 to 2240 in steps of 112, with a default of 1232 - the canonical Qwen-Image-Edit input resolution. If your model wants something else, pick the nearest preset.
  • Dimensions are snapped to the nearest alignment multiple and floored at one alignment block, so the resulting aspect ratio can shift by up to half a block from your original. That's the trade the node makes: clean grid over exact ratio.

The inputs that matter

Three inputs, two you'll set:

  • image - the IMAGE to align.
  • longest_edge - a dropdown of resolutions from 784 to 2240, default 1232.
  • alignment - 112, 56, or 224, default 112. Leave it unless your target model specifies otherwise.

Outputs: the resized IMAGE, width and height as INTs, and resolution_text as a STRING like "1232x896" - handy for logging or for wiring the resolution into a prompt or filename.

Installing it

Part of the EmAySee pack:

# ComfyUI Manager: search "ComfyUI_EmAySee_CustomNodes" and install
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes

Restart ComfyUI. No requirements.txt - this node only needs torch; the heavy Qwen dependencies live in the pack's QwenPromptFromImage node, not here.

Common issues

The aspect-ratio drift is the thing to watch. Because it snaps both dimensions independently to the grid, a 16:9 input can come out slightly narrower or wider than 16:9 - usually a couple percent, invisible for captioning, occasionally noticeable for edit work. If you need both grid alignment and exact ratio, pair this with EmAySee_QwenResolutionOptimizer (which picks a canonical ratio) or accept the small snap. Also, this node resizes only - it doesn't pad, crop, or denoise, so feed it a clean image. And remember the alignment convention is per-model: Qwen2.5-VL and Qwen-Image-Edit both want the 112 grid, but if you ever point this at a different VLM, check what it actually expects.

CategoryEmAySee/Image

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
longest_edgeCOMBO123214 options: 784, 896, 1008, 1120, 1232, 1344, +8
alignmentCOMBO1123 options: 112, 56, 224

Outputs (4)

NameTypeDescription
IMAGEIMAGE
widthINT
heightINT
resolution_textSTRING