Nodes/ComfyUI Smart Scaler/Aspect Ratio Adjuster
ComfyUI Node

Aspect Ratio Adjuster

9 video canvas

By babydjac·Created about a year ago·Updated about a year ago· 1
Aspect Ratio Adjuster
  • image
  • adjusted_image
  • new_ratio
target_ratio16:9
custom_ratio_width16.0
custom_ratio_height9.0
methodcrop

Aspect Ratio Adjuster is the node for the moment your image is the wrong shape for what comes next. It takes any image, crops or pads it until it hits a target ratio - 16:9, 4:3, 1:1, or your own custom one - and hands you back an image plus the new ratio as a string. It's the ratio-fixing sibling of Smart Aspect Scaler, which fixes size; the two work best as a pair.

Why you'd reach for it. Video models and editors are ratio snobs. Wan I2V wants a still that fills its target frame, and if you're assembling anything for a 16:9 video canvas - or doing img2vid where the first frame has to be exactly the shape of the output clip - an off-ratio source means letterbox bars or awkward empty space. This node settles the ratio question before anything generative touches the image. It's also handy for normalizing a mixed batch of screenshots or renders to a common framing without resizing them.

How it works

The important thing to understand: this node never resizes. It only removes or adds pixels. With method: crop (default) it center-crops the width or height away until the remaining pixels are exactly the target ratio. With method: pad it centers the image on a canvas of the correct ratio and fills the bars with black. That's the whole mechanism, and it's worth internalizing because it determines what you lose:

  • crop = you lose edges (or top/bottom). Good when you have detail to spare and hate bars.
  • pad = you get black bars. Good when you can't afford to lose any content, but bars are ugly and if you're feeding this into a generative pass, the model will happily treat the black as part of the image.

The custom_ratio_width and custom_ratio_height fields are only used when target_ratio is Custom - they're floats, so you can express something like 21:9 or 2.35:1 as precisely as you want. Defaults are 16 and 9, i.e. 16:9.

Outputs: adjusted_image is your new image, and new_ratio is a string of the actual pixel dimensions ratio, like "1280:720" - not the normalized "16:9" label. Handy for feeding a later step, but don't expect a pretty label.

Fitting it into a workflow

The ordering trick that trips people up: adjust the ratio first, then scale. Aspect Ratio Adjuster changes the shape but leaves you at whatever pixel size the crop/pad produced; Wan Video Frame Scaler or Smart Aspect Scaler then snaps that to a proper resolution bucket. Do it the other way and you'll fix the ratio only to have the scaler pull the aspect back toward the bucket - fighting yourself. The natural chain for an img2vid still: Aspect Ratio Adjuster → 16:9 → Wan Video Frame Scaler → 720p.

Like the other Smart Scaler nodes, it only processes the first frame of a batch, and it doesn't check whether your image already matches - a 16:9 source through a 16:9 target is a no-op, which is fine, just not worth a node in the graph.

Installation

Part of the comfyui-smart-scaler pack: ComfyUI Manager → search comfyui-smart-scaler → install → restart. Manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/babydjac/comfyui-smart-scaler.git
pip install torch Pillow numpy

No model files, no heavy deps - torch, Pillow and numpy are all you need. It shows up under SmartScaler in the node menu.

Common issues

The most common complaint is "it turned my image black around the edges" - that's pad, working as designed; switch to crop if bars bother you. The subtler trap is feeding the padded image into a generative step expecting it to ignore the bars; it won't. If your workflow is headed into an actual model, crop is usually the safer default so the bars never exist. And remember the node is ratio-only: if you're also expecting a specific pixel size out, you need a scaling node after it.

CategorySmartScaler

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
target_ratioCOMBO16:94 options: 16:9, 4:3, 1:1, Custom
custom_ratio_widthFLOAT16.01–100
custom_ratio_heightFLOAT9.01–100
methodCOMBOcrop2 options: crop, pad

Outputs (2)

NameTypeDescription
adjusted_imageIMAGE
new_ratioSTRING