Nodes/ComfyUI-Qwen-FrameKit/Smart Aspect Resize
ComfyUI Node

Smart Aspect Resize

Resize with the aspect ratio locked — change one side, the other follows

By uron83·Created 13 days ago·Updated 7 days ago· 0
Smart Aspect Resize
  • image
  • image
  • width
  • height
  • aspect_ratio
  • original_width
  • original_height
aspect_ratio
width1024
height1024
locked
fit
upscale_method
snap_to8
custom_aspect_width1
custom_aspect_height1
pad_color

Every ComfyUI user has the same ritual: you need an image at a specific size, you open the resize node, and you spend a minute doing the aspect-ratio arithmetic in your head to keep the picture from getting squashed. SmartAspectResize is the node that does that math for you - you change the width, it computes the height from the ratio, and the ratio never drifts. It's the kind of small quality-of-life node you didn't know you wanted until you're resizing a batch of reference images for an edit workflow.

What it's for

Two jobs, really. First, prepping an input image for a model that's picky about resolution - Qwen-Image-Edit, for instance, behaves noticeably better when its input is a controlled size, and models in general want dimensions that are a multiple of 8 for the VAE. This node's default snap_to of 8 enforces that for you. Second, it works as a pure size calculator: the image input is optional, so with nothing connected it still outputs the computed width, height, and aspect_ratio.

How it works

You pick a ratio source in aspect_ratio: from image (use the connected image's own ratio), custom (from the custom_aspect_width / custom_aspect_height inputs), or one of the presets from 1:1 up to 21:9. The locked dropdown decides which side drives the math - lock width and the height follows the ratio, lock height and the width follows, or lock aspect_ratio itself. A width or height of 0 means "use the source image's dimension," which is a handy escape hatch.

The fit mode then decides how the pixels actually land: contain fits the whole image inside the target box, crop scales up to cover and center-crops, pad fits inside and fills the leftover bars with pad_color (black or white), and stretch distorts to the exact dimensions. upscale_method is the usual ComfyUI ladder - nearest-exact, bilinear, area, bicubic, lanczos. The upsampling here is plain pixel resampling, the "more pixels" job from the upscaling world, not a generative upscaler; use lanczos for a clean downscale into an edit workflow and don't expect it to invent detail.

The inputs and outputs that matter

For most people it's three settings: aspect_ratio, locked, and fit, plus the width you actually want. Outputs are image, the resulting width and height, a reduced-fraction aspect_ratio string (so you get 16:9, not 1365.33:768), and original_width / original_height so downstream nodes can see what changed. There's a nice frontend touch: when aspect_ratio is from image and the image comes from a LoadImage node, the browser reads that file's real dimensions and keeps the other side in sync live as you type.

The gotchas

If you set aspect_ratio to from image but the image arrives from something that isn't LoadImage (a generation node, say), the frontend can't read the source dimensions and the ratio math falls back on whatever's in the width/height boxes. Use an explicit preset or custom there. stretch will happily deform your picture - use it only when you know why. And with no image connected, the image output is a blank black placeholder at the calculated size with original_width / original_height at 0; that's the calculator mode, and it wires straight into an EmptyLatentImage or a size widget.

Installing it

It's part of the four-node ComfyUI-Qwen-FrameKit pack:

cd ComfyUI\custom_nodes
git clone https://github.com/uron83/ComfyUI-Qwen-FrameKit.git

or search "Qwen FrameKit" in ComfyUI Manager, then restart and hard-refresh the browser. No extra packages - it uses only stock ComfyUI and PyTorch resize APIs, so there's no dependency roulette and no model to download. Found under image/resize → Smart Aspect Resize.

Categoryimage/resize

Inputs (11)

NameTypeDefaultDescription
aspect_ratioCOMBO12 options: from image, custom, 1:1, 2:3, 3:2, 3:4, +6
widthINT10240–16384
heightINT10240–16384
lockedCOMBO3 options: aspect_ratio, width, height
fitCOMBO4 options: contain, crop, pad, stretch
upscale_methodCOMBO5 options: nearest-exact, bilinear, area, bicubic, lanczos
snap_toINT81–256
imageoptIMAGE
custom_aspect_widthoptINT11–9999
custom_aspect_heightoptINT11–9999
pad_coloroptCOMBO2 options: black, white

Outputs (6)

NameTypeDescription
imageIMAGE
widthINT
heightINT
aspect_ratioSTRING
original_widthINT
original_heightINT