Nodes/ComfyUI-WBLESS/Dominant Axis Scale
ComfyUI Node

Dominant Axis Scale

Scale by the longest side — the pack's flagship sizing math

By LaoMaoBoss·Created about a year ago·Updated 5 days ago· 0
Dominant Axis Scale
  • width_a
  • height_a
  • width_b
  • height_b
  • width
  • height
  • scale_ratio
ratio0.50

This is the node the pack's README leads with, and it's easy to see why: it's the cleanest "fit one thing to another" math in the whole suite. Dominant Axis Scale takes a group A (the thing you want to scale) and a group B (your reference - think of it as the canvas), and scales A so that its longest side matches B's corresponding side, multiplied by a ratio you set. If A is wider than it is tall, A's width becomes B's width × ratio and the height follows to keep A's aspect ratio. If A is taller, the height drives it. The aspect ratio always stays A's own.

The whole point is "fill the reference without distorting." If you want a layer to span the full width of a 1024 canvas but never crop or stretch its proportions, this is the node: set ratio to 1 and the long side touches the matching canvas edge. It's the geometry that other workflows hand-build with a calculator, done live and recomputed every run.

How it works

Pure math, no models, no torch tricks - just the two dimension pairs and the ratio.

  • width_a / height_a - the dimensions you're scaling.
  • width_b / height_b - the reference baseline (the canvas).
  • ratio - the scaling factor applied to the dominant side. Default 0.5, range 0.01–1.

The logic branches on which of A's sides is longest: wide A scales width from B's width; tall A scales height from B's height. Either way, A's aspect ratio is preserved. Outputs are width (INT), height (INT) - the resulting dimensions - and scale_ratio (FLOAT), the multiplier that was applied to A, which you can feed into a resize elsewhere to apply the same scaling to something else.

Inputs are typed *, so they accept INTs or FLOATs from anywhere - Get Image Size, Get Mask Size, or hand-typed values.

Install

Part of ComfyUI-WBLESS:

cd ComfyUI/custom_nodes
git clone https://github.com/LaoMaoBoss/ComfyUI-WBLESS

restart ComfyUI, or install "ComfyUI-WBLESS" via ComfyUI Manager. No dependencies, no model files.

Troubleshooting

The gotcha is the ratio meaning: it scales the dominant side to ratio of the corresponding B side, not the area. Set it to 0.5 and a wide A becomes half the canvas width - which is a very different result from the pack's Area Based Scale, where 0.5 means half the area. If your layer comes out looking too big or too small, check which of the two nodes you grabbed. Zero dimensions on both axes return zeros, so guard your inputs. For "fit this to my canvas the way a designer would," this is the one you'll actually keep on your toolbar.

Category🌈WBLESS

Inputs (5)

NameTypeDefaultDescription
width_a*
height_a*
width_b*
height_b*
ratioFLOAT0.500.01–1

Outputs (3)

NameTypeDescription
widthINT
heightINT
scale_ratioFLOAT