ScaleOf
Work out the multiplier instead of guessing at it
- scale
ScaleOf answers one question: what do I multiply by to get from here to there? Two numbers in, one out. Target divided by source, at full floating-point precision, no rounding anywhere.
The author's own example is the clearest description: target 2.0, source 1.5, output 1.3333333333333333. That's it. It's the inverse of its sibling ScaleTo, which takes a scale and gives you dimensions; ScaleOf takes dimensions (or megapixels, or anything else with a ratio) and gives you the scale.
Inputs and outputs
Both inputs are required floats: target and source, each defaulting to 1, with a step of 0.01 and a range of essentially ±float-max. One output: scale, a FLOAT.
The interesting behaviour is in the validation, and it's all there to keep you out of a silent mess. Both inputs and the result must be finite, and source must be nonzero - divide by zero raises rather than handing you inf that gets swallowed by a downstream node. The inputs don't round to their step either, so you can wire in a computed value without it getting snapped to 0.01 and quietly skewing your upscale factor.
Typical use: you know your base image is 1024×1024 and you want 1536×1536. target 1536, source 1024, scale 1.5 - plug that into a latent upscale node, or into ScaleTo if you also need the dimensions for the second pass's latent. Same shape for "what multiplier turns a 1.5MP image into 4MP", since it doesn't care what the numbers measure.
The genuine beginner confusion: this is a single ratio, not an aspect ratio. It tells you how much bigger, never how the shape changed. If you're trying to convert a 4:3 source to 16:9, one ScaleOf node is the wrong tool and two of them won't help either - you want explicit target width and height.
Also: nothing here resizes anything, exactly like ScaleTo. It's a calculator on a wire so that your factor and your dimensions come from the same place. That matters more than it sounds in two-pass graphs, where a mismatched pair produces a stretched or cropped second pass and no error message.
Install
cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/lany42/comfyui-lany-nodes.git
# restart ComfyUI
Or search comfyui-lany-nodes in ComfyUI Manager (the registry entry reads "ComfyUI Lany Nodes"). No downloads, no model files, nothing beyond numpy and Pillow at runtime. It does need a current ComfyUI: the pack is written against the V3 node API and wants Python 3.13+, so on an older install you'll get a silently empty Lany Nodes category rather than an error.
If the node feels pointless on its own, that's fair - it's half of a pair. ScaleOf computes the factor, ScaleTo applies it and returns dimensions. Used together, there's exactly one scale value in the workflow and every node downstream agrees about it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| target | FLOAT | 1.00 | — |
| source | FLOAT | 1.00 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| scale | FLOAT | — |