Nodes/comfyui_gvf/Image size from aspect ratio
ComfyUI Node

Image size from aspect ratio

A calculator for latents, with a hidden convention trap

By gvfarns·Created about a year ago·Updated 9 months ago· 0
Image size from aspect ratio
    • Width
    • Height
    short_length1024
    aspect1.00

    If you've ever sat in front of an EmptyLatentImage doing mental math - "short side 1024, I want 3:2, so width is…" - this node exists to replace that arithmetic. SizeFromAspect (shown as "Image size from aspect ratio" in the comfyui_gvf pack) takes the length of the short side and an aspect ratio, and hands you back a Width and Height pair you can feed straight into EmptyLatentImage or any size-dependent node. It's a calculator, nothing more, and it's genuinely handy once you're switching ratios often.

    The inputs are the two you'd expect. short_length is an int between 256 and 4080 (default 1024) - the short side of your target image. aspect is a float from 0.1 to 10 (default 1.0, i.e. square). It outputs Width and Height, both ints.

    But read the source before you trust the numbers, because this is where the pack shoots itself in the foot. In the crop nodes (CropToAspectRatio, CropToAspectRatioMinMax), aspect means width ÷ height: 1.5 is a 3:2 landscape, 0.6667 is 2:3 portrait. SizeFromAspect uses the inverse convention, height ÷ width. Proof is in the code: for aspect > 1.0 it returns (short_length, int(short_length * aspect)) - so with short_length 1024 and aspect 1.5 you get Width 1024, Height 1536. That's a 2:3-ish portrait, not the 3:2 landscape the same number means everywhere else in this pack and in ComfyUI at large. The aspect < 1.0 branch is consistent with that flipped reading: aspect 0.6667, short 1024 gives (int(1024/0.6667), 1024) = (1536, 1024), a landscape pair.

    What does that mean in practice? Two honest options. Either treat the node as reading height÷width and enter the reciprocal of the ratio you actually want (for 3:2 landscape, type 0.6667), or simply remember that with this node landscape needs aspect < 1 and portrait needs aspect > 1, and don't copy numbers from the crop nodes. The "Width" and "Height" outputs are also capitalized differently from the snake_case outputs elsewhere in the pack - cosmetic, but it hints at how un-polished this one is. If the node ever gives you a wrong-feeling pair, check the orientation before you blame your model.

    Like everything in this pack, installation is painless: ComfyUI Manager → search "comfyui_gvf", or clone the repo into custom_nodes and restart.

    cd ComfyUI/custom_nodes
    git clone https://github.com/gvfarns/comfyui_gvf
    

    Zero dependencies, no models to fetch. Just remember the convention. It's a nice little time-saver that would be a genuinely good node if its aspect ratio weren't backwards from the rest of the pack - knowing that quirk is the whole battle.

    Categorygvf

    Inputs (2)

    NameTypeDefaultDescription
    short_lengthINT1024256–4080
    aspectFLOAT1.000.1–10

    Outputs (2)

    NameTypeDescription
    WidthINT
    HeightINT