Nodes/APW_Nodes/Image Size (Local Models)
ComfyUI Node

Image Size (Local Models)

Stop memorizing which resolution your model likes

By alessandroperilli·Created about a year ago·Updated 12 months ago· 4
Image Size (Local Models)
    • aspect_ratio
    • image_width
    • image_height
    • image_latent
    • batch_size
    Aspect Ratio
    Custom Width64
    Custom Height64
    Batch Size1

    Every diffusion model has a native resolution it was trained on, and generating far off it is how you get double heads and stretched bodies. Image Size (Local Models) exists so you never have to keep that table in your head again. It's a dropdown of the preset resolutions that matter - organized by megapixel tier across FLUX.1, SD 3.5, SDXL, and SD 1.5 - plus a custom option and batch size, and it hands you the dimensions and a ready-to-use latent in one shot.

    It's part of APW_Nodes, the small utility pack Alessandro Perilli pulled out of his "AP Workflows for ComfyUI" suite. Where the stock approach is an EmptyLatentImage node plus a scribbled aspect-ratio cheat sheet, this is the whole thing in one node: pick the model family, get the right dims.

    How it works

    The Aspect Ratio dropdown maps to a hardcoded dictionary of 21 real resolutions, grouped so you pick by megapixels rather than by model - smart, because FLUX and SD 3.5 both happily run 1MP and 2MP. Select a preset and the node returns five outputs: an aspect_ratio string in "WxH" form, image_width, image_height, an image_latent blank, and batch_size.

    The latent is built as torch.zeros([batch, 4, H//8, W//8]) - the same 4-channel, 8x-downsampled shape an EmptyLatentImage produces, because the VAE compresses each side by 8. In practice that means this node replaces EmptyLatentImage: wire image_latent straight into your KSampler and you've dropped a node from the graph.

    The inputs that matter

    • Aspect Ratio - presets grouped by tier: 2MP and 1MP for FLUX.1 / SD 3.5, 1MP for SDXL, and 0.3-0.5MP for SD 1.5. The dashed lines (--------- FLUX.1, SD 3.5 ---------) are just labels.
    • Custom Width / Custom Height - 64 to 8192, used when you pick custom.
    • Batch Size - 1 to 64, default 1. It feeds both the latent batch and the batch_size output.

    Wiring it up

    Three wires do most of the work: image_latent into the sampler, batch_size into anything batching, and the aspect_ratio string ("1920x1088", say) into a prompt template or API parameter if you build metadata from it. Because aspect_ratio is a wildcard-typed output, it'll plug into nearly any string-ish input.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/alessandroperilli/apw_nodes
    

    Restart ComfyUI, or search "APW Nodes" in ComfyUI Manager. No extra Python deps, no model downloads. Note the repo is archived - the author's successor is OCS_Nodes - but it installs and runs as-is.

    Where people get burned

    The custom-resolution trap: the latent is sized with integer floor division (H//8), so a "custom" 100x100 becomes a latent that decodes back to 96x96. Always set custom dims in multiples of 8, or you'll wonder why your output is a hair smaller than you asked. Second, remember these presets are native resolutions - if you select the FLUX 2MP 16:9 preset but your workflow then upscales or crops, that's your doing. The node's job is handing you the right starting point, not babysitting what happens after the sampler.

    CategoryAPW Nodes

    Inputs (4)

    NameTypeDefaultDescription
    Aspect RatioCOMBO25 options: custom, --------- FLUX.1, SD 3.5 ---------, 1152x1728 (2:3 | 2MP), 1216x1664 (3:4 | 2MP), 1728x1152 (3:2 | 2MP), 1664x1216 (4:3 | 2MP), +19
    Custom WidthINT6464–8192
    Custom HeightINT6464–8192
    Batch SizeINT11–64

    Outputs (5)

    NameTypeDescription
    aspect_ratio*
    image_widthINT
    image_heightINT
    image_latentLATENT
    batch_sizeINT