Nodes/zhangp365/ComfyUI-utils-nodes/Aspect Ratio Size Selector
ComfyUI Node

Aspect Ratio Size Selector

Pick a ratio and a size tier instead of typing pixels

By zhangp365·Created 2 years ago·Updated 5 months ago· 135
Aspect Ratio Size Selector
    • width
    • height
    • batch_size
    aspect_ratio
    size
    divisible_by
    batch_size1
    input_width1024
    input_height1024

    Instead of doing the arithmetic yourself every time ("what's 16:9 at roughly 2K, again?"), this node lets you pick an aspect ratio and a size tier from dropdowns and it hands you the actual width/height pixel values to feed your latent. It's a small node, but it removes a specific bit of friction that shows up constantly when you're switching between portrait, landscape, and square outputs across a session.

    The controls

    • aspect_ratio - 16 choices, including 1:1, 1:2, 3:5, 5:3, 2:1, 3:1, 1:3, 9:16, 16:9, 3:4, 4:3, 2:3, plus four more beyond that list. Per the README, one of the options is an auto mode that passes your input_width/input_height straight through unchanged, instead of computing a ratio-based size - useful if you want this node purely for the divisibility rounding described below and not for picking a preset shape at all.
    • size - 1k, 2k, or 4k, the target resolution tier the aspect ratio gets applied at.
    • divisible_by - none, 8, or 16. Rounds the computed width/height to a clean multiple. 8 matches the grid SD/SDXL/Flux VAEs actually downsample on; 16 is the coarser grid some newer or video-oriented architectures prefer. Same underlying reason this pack's ImageResizeTo8x node exists - misaligned dimensions cause downstream rounding mismatches.
    • batch_size - 1 to 4096, a pure pass-through. It doesn't affect the computed width/height at all; it just gives you a wired batch_size output so one node can feed both your size calculation and your EmptyLatentImage without a separate primitive.
    • input_width / input_height (optional, default 1024 each) - only relevant if aspect_ratio is set to the auto/pass-through option.

    Outputs: width, height, batch_size - all INT, ready to wire straight into a latent or resize node.

    Choosing a size tier that matches your model

    1k lines up closely with what SDXL was actually trained on - its documented trained buckets are 1024x1024, 1152x896, 1216x832, 1344x768, and 1536x640 (and their rotations), so several of this node's 1k-tier ratio outputs should land close to those numbers. 2k and 4k are squarely newer-model territory - Flux and its successors handle much higher resolutions comfortably, where SDXL would start producing duplicated anatomy or tiling if you pushed it that far without upscaling. Match the tier to what your checkpoint actually was trained at, not just to what output size you want the file to be.

    Installing it

    ComfyUI Manager: search "ComfyUI-utils-nodes." Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/zhangp365/ComfyUI-utils-nodes
    

    Restart ComfyUI. No dependencies, pure arithmetic.

    Watch for

    If your output size doesn't match what you expected, the first thing to check is whether aspect_ratio is actually set to a ratio, versus that auto/pass-through option - in pass-through mode, size is ignored entirely and you'll get back whatever input_width/input_height say, which is easy to forget you set months ago at their 1024 defaults.

    Categoryutils/numbers

    Inputs (6)

    NameTypeDefaultDescription
    aspect_ratioCOMBO16 options: 1:1, 1:2, 3:5, 5:3, 2:1, 3:1, +10
    sizeCOMBO3 options: 1k, 2k, 4k
    divisible_byCOMBO3 options: none, 8, 16
    batch_sizeINT11–4096
    input_widthoptINT10241–8192
    input_heightoptINT10241–8192

    Outputs (3)

    NameTypeDescription
    widthINT
    heightINT
    batch_sizeINT