Dimension Scale (CCN)
Match a reference resolution without doing the math in your head
- width
- height
- info
"You have a 1344x768 source and you want it scaled to fit a 1920x1080 reference - what are the exact output dimensions?" That's a question ComfyUI workflows ask constantly, and the answer is usually a bit of mental math or a calculator tab. Dimension Scale (CCN) does it in the graph: it takes input width/height, scales them relative to a reference resolution, floors the results to a multiple of your choice, and outputs clean integers - no image tensor required. It's a pure number utility, and it's quietly one of the more useful plumbing nodes in the pack.
How it works
Four scale_type modes, each with a different idea of what "match the reference" means:
scale_width- match the reference width; height follows proportionally. It multiplies both dimensions byref_width / width, so a 960-wide input scales by 2x and keeps its aspect ratio.scale_height- the mirror image: match reference height, width follows.match_exact- output the reference dimensions exactly, ignoring aspect ratio entirely. Only reach for this when you genuinely want a forced size (and expect distortion).smart_scale(default) - the interesting one: pick whichever axis needs the least percentage change, and scale proportionally along it. This is the "fit within without cropping" behavior, and it's what most people actually want when they say "scale to fit."
Every mode floors both outputs to a multiple of round_to (default 8) - the resolution-safety multiple that keeps dimensions compatible with latent-space models.
Inputs and outputs
width, height (input dimensions), ref_width, ref_height (reference), scale_type, round_to. Outputs: width, height (the computed integers), and info - a string describing what the mode did, including the scale factor and percent deltas. Wire the ints straight into your Empty Latent Image width/height or a resize node.
Install
ComfyUI Manager → search ComfyCollectorNodes → Install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/valkymaera/ComfyCollectorNodes
Restart, no pip step. Under the (CCN) suffix.
Where it earns its place
The classic use is driving Empty Latent Image from a reference image's dimensions - measure the reference, scale your working resolution to match, keep everything in multiples of 8. Because it's all integers and no tensor math, it's also a nice input to batch jobs where you compute a size once and fan it out. The caveats are the usual rounding ones: flooring to multiples of 8 means smart_scale output won't be pixel-perfect against the reference, which is by design (model compatibility beats exactness), and match_exact will happily produce a distorted aspect ratio if you don't watch it. For "scale my generation to sit beside this reference," it's the node you didn't know you wanted.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 10241–65536 | — |
| height | INT | 10241–65536 | — |
| ref_width | INT | 19201–65536 | — |
| ref_height | INT | 10801–65536 | — |
| scale_type | COMBO | smart_scale | 4 options: scale_width, scale_height, match_exact, smart_scale |
| round_to | INT | 81–64 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| info | STRING | — |