Nodes/wlsh_nodes/Empty Latent by Pixels (WLSH)
ComfyUI Node

Empty Latent by Pixels (WLSH)

Empty Latent by Pixels (WLSH)

By wallish77·Created 3 years ago·Updated 2 years ago· 144
Empty Latent by Pixels (WLSH)
    • latent
    • width
    • height
    aspect
    direction
    megapixels1.00
    batch_size1

    SDXL has a fixed short list of trained resolutions and you should stick to it, but plenty of models don't work that way - they're trained on a range of resolutions within a target pixel budget, and what matters is total megapixel count more than any specific width/height pair. This node is built for that world: pick an aspect ratio, pick landscape or portrait, tell it how many megapixels you want, and it computes the width and height for you and builds the empty latent to match.

    This is genuinely the more future-proof way to think about resolution on a lot of current models. The rigid "must be exactly 1024x1024 or a handful of alternates" constraint was specifically an SDXL-era thing tied to how that model's positional encoding was trained; newer architectures increasingly take any resolution within a megapixel band and degrade gracefully rather than falling apart when you're slightly off. A megapixel-driven latent generator fits that pattern better than a fixed lookup table does - you're expressing "I want roughly this much detail budget" rather than "I want exactly this pixel grid."

    Inputs: aspect is a 12-option enum covering everything from 1:1 through wide options like 21:9, 3:1, and 4:1 - square, standard photo ratios, and ultra-wide, all in one dropdown. direction is landscape or portrait. megapixels is the real control here - a FLOAT from 0.01 to 16, default 1 (where "1MP" means 1024×1024's pixel count, per the pack's own convention, not the more common 1,000,000-flat definition - worth knowing if you're doing the math yourself). batch_size (1–64, default 1) sets how many latents this run produces.

    Outputs: latent is the ready-to-sample LATENT tensor. width and height come back as INTs too, computed from your aspect ratio and megapixel target - handy for feeding into anything downstream that wants the actual dimensions as numbers rather than reading them off the latent's shape.

    Installing it: through ComfyUI Manager, search "wlsh_nodes"; or clone directly:

    cd ComfyUI/custom_nodes
    git clone https://github.com/wallish77/wlsh_nodes
    

    Restart ComfyUI afterward. No model downloads, no extra dependencies - it's arithmetic plus latent construction.

    Where this can bite you: cranking megapixels up toward the 16 ceiling on an SD1.5-era or SDXL-era model isn't going to give you a better image - those architectures weren't trained to generate coherently at that scale in one pass, and you'll get duplicated subjects, tiling artifacts, or a soft mess well before you get more real detail. Generate at a sane megapixel count for your model's actual training range, then upscale afterward if you want more pixels - that's still the standard two-step pattern regardless of how flexible the model's resolution handling is. Also note that at very low megapixel values combined with an extreme aspect ratio (say 4:1 at 0.05MP), you can end up with one dimension rounding down to something impractically small - if a generation looks oddly cropped or blank, check the actual width/height outputs before assuming the prompt or sampler is at fault.

    CategoryWLSH Nodes/latent

    Inputs (4)

    NameTypeDefaultDescription
    aspectCOMBO12 options: 1:1, 5:4, 4:3, 3:2, 16:10, 16:9, +6
    directionCOMBO2 options: landscape, portrait
    megapixelsFLOAT1.000.01–16
    batch_sizeINT11–64

    Outputs (3)

    NameTypeDescription
    latentLATENT
    widthINT
    heightINT