Nodes/comfyui-AGSoft/📐AGSoft Aspect Ratio
ComfyUI Node

📐AGSoft Aspect Ratio

Stop doing resolution math in your head — let a calculator pick your canvas size

By Art-xmaster·Created 12 months ago·Updated a day ago· 23
📐AGSoft Aspect Ratio
    • width
    • height
    • ratio
    • display
    preset1:1
    custom_ratio16:9
    basewidth
    base_value1024
    megapixels_value1.0
    multiple8
    roundinground

    You want a 16:9 canvas around 1024px on the long side, but every time you type the numbers you get 1024×575 and the model silently ignores your aspect and crops - or worse, stretches anatomy because the resolution sits between its native training ratios. 📐AGSoft Aspect Ratio is the boring fix: tell it the ratio, tell it what's fixed, and it hands you exact, multiple-aligned width and height as plain numbers. No sampling, no latents, no AI. It's a calculator that lives inside your graph so the math can't drift.

    It's one node in the big AGSoft pack, which is basically a one-author toolbox of 100+ utility nodes (loops, text, video, masks). This one does one job and does it purely in Python - there's no torch, no model, nothing to download. The source is a ratio parser, a couple of multiplications, and a rounding helper.

    How it works

    You pick a ratio, an anchor, and a rounding rule, and the node derives the other dimension. The base dropdown decides what "1024" actually means:

    • width or height - fix that side, derive the other from the ratio.
    • longest / shortest - fix the bigger or smaller side regardless of orientation, which is the right choice for "a 2.39:1 shot at ~2048 wide" without caring about landscape vs portrait.
    • megapixels - fix the total area instead, so 1.0 MP gives a ~1:1 1024×1024 but a wider frame at the same pixel budget.

    Everything then gets snapped to multiple (default 8, set 32 or 64 to match what a given VAE wants) using round, floor, or ceil. That alignment step is the part that actually saves you: latent models are picky about divisibility, and generating off-multiple just gets you silent cropping or duplicated anatomy when you push past native resolution.

    The inputs that matter

    • preset - 15 presets (1:1, 16:9, 21:9, 9:16, …) plus custom.
    • custom_ratio - only read when preset = custom; accepts strings like 16:9, 1.85:1, 2.39:1.
    • base + base_value - what's fixed and its value in pixels (or megapixels_value when base is megapixels). Note the pair: change base to megapixels and the base_value field is ignored, and vice versa.
    • multiple and rounding - the alignment rules.

    Outputs and where they go

    You get four: width (INT), height (INT), ratio (FLOAT), and display (STRING - a ready "1920×1080 (16:9)" line you can pipe into a Show Text or into a filename). These are plain numbers, so wire them anywhere that takes an INT/STRING: a resize node, a crop, a text overlay. AGSoft's own 🧊Empty Latent Plus has this same size engine built in, so if you're using that you don't need this node - reach for the standalone version when you want dimensions for something other than generating, like preparing a consistent canvas across a whole batch.

    Installing it

    It's part of comfyui-AGSoft, installed once for the whole pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Art-xmaster/comfyui-AGSoft
    

    then restart ComfyUI - or search comfyui-AGSoft in ComfyUI Manager and click install. The pack declares numpy, opencv-python, and translators in its requirements, but this specific node doesn't touch any of them; you're not pulling in anything heavy to use it.

    Gotchas

    Keep custom_ratio in W:H form - the parser accepts x, /, ,, ; as separators, but a malformed string raises a clear ValueError. And don't set multiple to 1 thinking you'll get exact values: that's the "no rounding" mode, but the node still clamps results up to at least the multiple, so tiny anchors like 10px become 8 or 16. For normal 512–2048 work, default 8 with round is exactly right.

    CategoryAGSoft/nodes

    Inputs (7)

    NameTypeDefaultDescription
    presetCOMBO1:1Preset aspect ratio. 'custom' = use your own from custom_ratio. --- Пресет пропорции. 'custom' = своя из custom_ratio.
    custom_ratioSTRING16:9Custom ratio (W:H), used only when preset='custom'. Supports '16:9', '1.85:1', '2.39:1'. --- Своя пропорция (W:H), работает только при preset='custom'. Поддержка '16:9', '1.85:1', '2.39:1'.
    baseCOMBOwidthWhich value to fix: width / height / longest / shortest side / total megapixels. --- Что фиксировать: width / height / длинную / короткую сторону / суммарные мегапиксели.
    base_valueFLOAT10241–16384Fixed side value (px) for width/height/longest/shortest. - Значение фиксируемой стороны (px) для width/height/longest/shortest.
    megapixels_valueFLOAT1.00.1–100Total megapixels, step 0.1 (used only when base='megapixels'). - Суммарные мегапиксели, шаг 0.1 (работает только при base='megapixels').
    multipleINT81–128Align dimensions to a multiple (8/32/64). 1 = no rounding. --- Выравнивание размеров под кратность (8/32/64). 1 = без округления.
    roundingCOMBOroundRounding method: floor (down) / round (nearest) / ceil (up). --- Метод округления: floor (вниз) / round (ближайшее) / ceil (вверх).

    Outputs (4)

    NameTypeDescription
    widthINT
    heightINT
    ratioFLOAT
    displaySTRING