Nodes/ComfyUI_EmAySee_CustomNodes/EmAySee_ Qwen Ratio Lock
ComfyUI Node

EmAySee_ Qwen Ratio Lock

Pin an image to Qwen's native aspect ratio before it goes downstream

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee_ Qwen Ratio Lock
  • image
  • IMAGE

EmAySee Qwen Ratio Lock forces an image to a fixed aspect ratio - specifically 4000:2904 (about 1.377, close to 3:2) - while keeping the longest edge at its original size. One input, one output, no knobs. It's the simplest member of the pack's Qwen prep family, and it has one specific job: normalize the shape of images before they reach a Qwen-based model that was trained on that aspect.

If you've read the other nodes in this set, the logic is consistent. Qwen's vision models are trained on a set of canonical resolutions and aspect ratios, and inputs that wander far from them pay for it in alignment and quality. Ratio Lock is the crude version of that normalization: it keeps your longest edge intact and squashes the other axis to match the 4000:2904 ratio. A landscape image stays roughly landscape; a tall portrait gets squeezed toward the model's preferred shape. There are no settings to argue with, which is either a feature or a frustration depending on your tolerance.

How it works

The implementation is a one-liner in spirit. If the image is wider than tall, it keeps the width and sets the height to width × (2904 / 4000); if taller than wide, it keeps the height and sets the width to height × (2904 / 4000). Either way the longest edge is untouched and the other edge is resized with bilinear interpolation to hit the ratio. If the image is already at that ratio, it's passed through untouched - no pointless resample.

One honest note: because it preserves the longest edge and recomputes the other, the output dimensions depend entirely on your input. There's no snap to a grid here - for that you'd use EmAySee_QwenPixelAligner or EmAySee_QwenResolutionOptimizer. Ratio Lock is the "just fix the shape" step, and it's often best used before one of those.

The inputs that matter

Exactly one:

  • image - the IMAGE to reshape.

One output, the reshaped IMAGE. No width/height/ratio outputs here - if you want those numbers, the other Qwen prep nodes give them to you.

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 - torch only.

Common issues

The big caveat is that this node distorts. Squeezing a 9:16 portrait into a 1.377 ratio via resample doesn't crop anything - it stretches the pixels, so things look wider than they should. If you're prepping an image for editing or captioning and the subject matters, a stretch can subtly deform it, and this node gives you no crop option. The fix is to use it as a shape gate rather than a final step: run it when the aspect matters more than the pixels, or pair it with EmAySee_QwenResolutionOptimizer's crop mode when you want shape without distortion. It's also worth confirming 4000:2904 is actually what your target model expects - this is the author's chosen ratio baked into the code, and it's not configurable.

CategoryEmAySee

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE