Nodes/ComfyCollectorNodes/Dimension Scale (CCN)
ComfyUI Node

Dimension Scale (CCN)

Match a reference resolution without doing the math in your head

By valkymaera·Created 4 months ago·Updated 10 days ago· 1
Dimension Scale (CCN)
    • width
    • height
    • info
    width1024
    height1024
    ref_width1920
    ref_height1080
    scale_typesmart_scale
    round_to8

    "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 by ref_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.

    CategoryComfyCollectorNodes/Dimension

    Inputs (6)

    NameTypeDefaultDescription
    widthINT10241–65536
    heightINT10241–65536
    ref_widthINT19201–65536
    ref_heightINT10801–65536
    scale_typeCOMBOsmart_scale4 options: scale_width, scale_height, match_exact, smart_scale
    round_toINT81–64

    Outputs (3)

    NameTypeDescription
    widthINT
    heightINT
    infoSTRING