Nodes/ComfyUI_EmAySee_CustomNodes/EmAySee_ Qwen Resolution Optimizer
ComfyUI Node

EmAySee_ Qwen Resolution Optimizer

Snap your image to the nearest Qwen aspect ratio, scaled to taste

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee_ Qwen Resolution Optimizer
  • image
  • IMAGE
  • width
  • height
  • aspect_ratio_name
scale_multiplier1.0
methodcrop
upscale_methodbicubic

EmAySee Qwen Resolution Optimizer takes an image, figures out which of seven canonical Qwen aspect ratios it's closest to, and resizes it to that ratio at a base resolution you can scale. Out come the resized image, the width, the height, and a readable label like 3:2 Classic @ 1.0x (1232x896). It's the "normalize shape AND resolution for Qwen" step in one node.

The reasoning is the same as the rest of this pack's Qwen prep family: Qwen vision models train on a fixed set of aspect ratios, and straying from them costs you alignment and quality. Where QwenRatioLock just forces one ratio and QwenPixelAligner snaps to a pixel grid, this one is the middle ground with taste - it picks the nearest of the model's actual ratios (1:1, 4:3, 3:2, 16:9, 3:4, 2:3, 9:16), each at a Qwen-native base resolution that's already a multiple of 112, then lets you scale that base up or down with scale_multiplier.

How it works

The flow: compute your input's aspect ratio, find the closest match among the seven targets, take that target's base dimensions, multiply both by scale_multiplier, and snap to a multiple of 112. Then, depending on method:

  • crop - center-crops your image to the target aspect before resizing, so nothing gets distorted. This is the one to use when the subject's proportions matter.
  • stretch - skips the crop and just resamples to the target dimensions, which distorts the shape to fit.

The upscale_method (bicubic, bilinear, nearest-exact, area) controls the resample quality. The output label is genuinely useful - aspect_ratio_name tells you both the ratio it chose and the final dimensions, so you can log it or feed it into a filename.

The inputs that matter

Four inputs:

  • image - the IMAGE to optimize.
  • scale_multiplier - FLOAT from 0.1 to 4.0, default 1.0. How much of the base resolution you want. 1.0 gives the canonical sizes (1008×1008 for square, 1344×784 for 16:9); lower for smaller batches, higher for more detail.
  • method - crop (default) or stretch.
  • upscale_method - default bicubic.

Outputs: IMAGE, width, height, aspect_ratio_name.

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; the heavy model dependencies live in QwenPromptFromImage.

Common issues

The one real caveat is that this is an older, pre-fix version of the crop logic - see the FXD variant in this pack for the corrected one. In short, this node crops to the nominal target ratio, then rounds the resize target to a multiple of 112, and those two numbers can disagree by a few pixels, which is how a tiny distortion sneaks in. For most captioning and prep work it's invisible; if you're doing precise edit passes, use EmAySee_QwenResolutionOptimizerFXD. Also, the base resolutions are fixed per ratio - if your target model doesn't match Qwen's expected sizes, the "optimizer" part of the name overpromises. And remember stretch distorts: it's there for when shape doesn't matter, not as a quality option.

CategoryEmAySee_Nodes/Image/Alignment

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
scale_multiplierFLOAT1.00.1–4
methodCOMBOcrop2 options: crop, stretch
upscale_methodCOMBObicubic4 options: bicubic, nearest-exact, bilinear, area

Outputs (4)

NameTypeDescription
IMAGEIMAGE
widthINT
heightINT
aspect_ratio_nameSTRING