Nodes/ComfyUI-SizeFromPresets/Empty Latent Image From Presets (SDXL)
ComfyUI Node

Empty Latent Image From Presets (SDXL)

The Empty Latent Image that keeps you on SDXL's trained sizes

By nkchocoai·Created 3 years ago·Updated about a year ago· 13
Empty Latent Image From Presets (SDXL)
    • latent
    • w
    • h
    preset
    batch_size1

    This is the node you'll actually reach for daily from this pack: a drop-in replacement for ComfyUI's core Empty Latent Image that swaps the width/height text boxes for a dropdown of SDXL's trained resolutions. Pick a preset, get an empty latent plus its w and h, wire the latent into the sampler. That's the whole workflow - it's the default starting node for any text-to-image graph, just with better defaults.

    Why does the dropdown matter? SDXL was trained on a specific set of aspect ratios, all around one megapixel: 1024x1024, 1152x896, 896x1152, 1216x832, 832x1216, 1344x768, 768x1344, 1536x640, 640x1536. Generate at one of these and you're in the model's comfort zone. Type in an arbitrary size and you risk the classic off-ratio failure modes - stretched anatomy, doubled heads, repeated patterns. The presets are the guardrail, and this node is the easiest way to stay inside it. If you want true 16:9, the trick is to generate at the closest trained ratio and crop or hires-fix afterward, not to force an untrained rectangle.

    It's from nkchocoai's ComfyUI-SizeFromPresets, a minimal pack that reads size presets from CSV files - no models, no dependencies beyond what ComfyUI already has.

    How it works

    The implementation is basically core ComfyUI's EmptyLatentImage with the size inputs replaced by a preset lookup:

    latent = torch.zeros([batch_size, 4, h // 8, w // 8])
    

    A zero latent at 1/8 scale, 4 channels. The preset string like "1216 x 832" gets parsed back into w, h, and the latent is sized from that. All nine SDXL presets are divisible by 8, so the latent decodes to exactly the size the dropdown advertises.

    The inputs that matter

    • preset - the dropdown, nine options from presets/sdxl.csv. This is the whole point.
    • batch_size - 1 to 4096, how many empty latents to stack. Default 1.

    Outputs: latent into the sampler's latent input, plus w and h INTs you can route elsewhere or read for bookkeeping.

    Where people get burned

    Not much to trip on here, which is why it's the safe recommendation. The one thing to remember: the preset list is a file, not a fixed menu. presets/sdxl.csv is just rows of width,height, and the dropdown is built from it at import time. Want a custom resolution that's still "trained-ish"? Add a row and restart ComfyUI. This is the pack's real superpower - you get the reproducibility of a dropdown and the ability to change the menu without touching code.

    Two gotchas: edits to the CSV only appear after a ComfyUI restart, since the list is read once at startup. And the pack hardcodes the folder name ComfyUI-SizeFromPresets when looking for that CSV, so don't rename the clone or every node in the pack fails to load.

    Install

    Via ComfyUI Manager, search "ComfyUI-SizeFromPresets". Or:

    cd <ComfyUI>/custom_nodes
    git clone https://github.com/nkchocoai/ComfyUI-SizeFromPresets.git
    

    Restart, then add the node from the SizeFromPresets category in the node menu. No requirements.txt, no models to download, nothing else to configure.

    CategorySizeFromPresets

    Inputs (2)

    NameTypeDefaultDescription
    presetCOMBO9 options: 1024 x 1024, 1152 x 896, 896 x 1152, 1216 x 832, 832 x 1216, 1344 x 768, +3
    batch_sizeINT11–4096

    Outputs (3)

    NameTypeDescription
    latentLATENT
    wINT
    hINT