Nodes/ComfyUI-ppm/Empty Latent Image (Aspect Ratio)
ComfyUI Node

Empty Latent Image (Aspect Ratio)

Pick a ratio, not two numbers

By pamparamm·Created 2 years ago·Updated about 10 hours ago· 265
Empty Latent Image (Aspect Ratio)
    • LATENT
    resolution512
    ratio1.000
    step64
    batch_size1

    The stock EmptyLatentImage makes you type a width and a height. This one lets you think the way you actually think - "I want a portrait at roughly 1MP" - by giving you a target resolution and an aspect ratio, and it does the pixel math for you. Small quality-of-life node, but a genuinely nice one if you switch aspect ratios a lot.

    The problem it quietly solves

    Every model has a resolution sweet spot: SD1.5 wants around 512, SDXL wants around 1024, and going too far off it gives you duplicated subjects and mush. So when you want a 16:9 landscape, you can't just crank the width - you have to keep the total pixel count near the model's target while changing the shape. Doing that by hand means arithmetic every time: "okay, 1024² is a megapixel, so 16:9 at a megapixel is... 1216×684-ish, round to a multiple of 8..." Annoying, and easy to get wrong.

    This node takes the target resolution and the ratio and computes width and height for you, keeping the pixel budget roughly constant and snapping the result to valid multiples. Change the ratio, the resolution stays sane automatically. That's the win.

    The inputs

    • resolution (default 512) - your target base resolution, the "how big overall." Set this to your model's sweet spot (512 for SD1.5, 1024 for SDXL). The node uses it to anchor the total pixel count.
    • ratio (default 1) - the aspect ratio as a single number. 1 is square, values above 1 are landscape (wider), below 1 are portrait (taller). So ~1.78 is 16:9, ~0.56 is 9:16, ~1.33 is 4:3. The slider spans 0.15 to ~6.67, so you can go extreme if you want a banner or a tall strip.
    • step (default 64) - the rounding increment for the computed dimensions. Latent-friendly models want multiples of 8 at minimum; 64 keeps you safely aligned and is a fine default.
    • batch_size (default 1) - how many latents in the batch, same as the stock node.

    Output is a LATENT you feed straight into your sampler, exactly where an EmptyLatentImage would go.

    Install

    No models, no deps:

    • ComfyUI Manager: search "ComfyUI-ppm", install, restart.
    • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/pamparamm/ComfyUI-ppm, then restart.

    When it's worth it

    If you only ever generate square 1024s, the stock node is fine and you don't need this. It pays off when you're bouncing between aspect ratios - portraits, then a wide cover, then a phone-shaped 9:16 - and you don't want to recompute dimensions each time or keep a cheat-sheet of "SDXL-safe resolutions" open in another tab. Set resolution once, spin the ratio, and you stay in the model's happy zone without thinking about it.

    Two things to keep in mind. Set resolution to match your model - leave it at the 512 default while running SDXL and you'll get undersized, soft images. And the ratio is a number, not a "16:9" string, so if you want a named ratio, convert it: divide width by height (16÷9 ≈ 1.78) and type that. Extreme ratios still obey the model's limits - a 6:1 strip on SDXL will look stretched and repeat elements no matter how clean the math is; the node keeps your pixel budget sane, it can't make the model like a weird shape.

    Pack rule: if it errors after an update, delete and re-add the node.

    Categorylatent

    Inputs (4)

    NameTypeDefaultDescription
    resolutionINT51216–16384
    ratioFLOAT1.0000.15–6.666666666666667
    stepINT648–128
    batch_sizeINT11–4096

    Outputs (1)

    NameTypeDescription
    LATENTLATENT