Nodes/HWP Nodes/HWP Aspect Size
ComfyUI Node

HWP Aspect Size

Type a Ratio, Get VAE-Safe Width and Height

By hwprinz·Created 2 months ago·Updated 18 days ago· 2
HWP Aspect Size
  • model
  • width
  • height
  • latent
◄model_type▾►
◄aspect_ratio_width1►
◄aspect_ratio_height1►
◄downscale_factor32►
◄batch_size1►

You want a 5:2 banner out of SDXL, so you do the maths by hand in Empty Latent Image: 1024 is the good area, so 5:2 means… 1600×640? You pick one, a face comes out stretched, and you're back at the number fields. HWP Aspect Size ends that loop - pick the model, type the ratio as two integers, get back a width, a height and an empty latent of that size. It's one node in a small pack by H.W. Prinz (v0.9.9, MIT, Comfy Registry), a descendant of DJZ-Nodes' Aspect Size V2 with the presets renamed to name the models they fit.

The mechanism: a fixed pixel budget, a shape you choose

Every model_type preset is just a total pixel area - SDXL, FLUX is 1024², QWEN is 1328², 4K is 2880². Your ratio decides how that area gets split:

width  = sqrt(area * ratio)
height = area / width

Both numbers then get rounded up to the nearest multiple of downscale_factor: area constant, shape changed, output always VAE-legal. 4K with 16×9 and factor 16 is exactly 3840×2160; SDXL, FLUX at 16×9 comes out 1376×768, a hair wide of 16:9 thanks to that round-up.

The inputs you actually touch

model_type is the pixel budget, and it's the one field not to guess at. Several models share a budget, which is why entries read like lists: SDXL, FLUX covers SDXL, FLUX.1, SD3, Kolors and Krea 2, and QWEN's 1328² comes from the official Qwen-Image resolution table. The 1440x, 4K, 3072x, 8K and 16K entries are generic budgets.

aspect_ratio_width and aspect_ratio_height are free integers; 5 and 2 gives 5:2.

downscale_factor is the one people get wrong. It's the multiple both dimensions snap to: 8 for SD 1.5 / 2.1 / SDXL, 16 for FLUX.1 / SD3 / Qwen-Image 1.x, 32 for Qwen-Image 2.x and GLM-Image. Don't go below 8 even though the widget allows it - the latent output is built at height // 8 × width // 8, so anything under 8 leaves the latent grid out of step with the numbers the node prints. batch_size is just the latent's batch; leave it at 1.

Outputs, and the optional model input

Three outputs: width (INT), height (INT), latent (LATENT). Wire the latent into your sampler and delete your Empty Latent Image node; send the INTs anywhere that wants a width or height, or right-click a downstream widget and Convert to input. The resolved size also prints below the node after a run, like the built-in Get Image Size.

With model unconnected the latent is byte-for-byte Empty Latent Image output: 4 channels at 1/8 plus the downscale_ratio_spacial tag, which the built-in KSampler and SamplerCustomAdvanced read to convert to the model's native layout themselves - so this works everywhere. With model connected (the same MODEL chain that feeds your sampler, e.g. your LoRA output) the node does that conversion up front, reading channel count and spatial ratio off the model, and drops the tag so nothing rescales it twice.

You need the connected version for custom samplers that don't rescale empty latents - RES4LYF's ClownsharKSampler is the one the author names, and since RES4LYF usually arrives as a one-line sampler swap, that's how you end up handing a 4-channel latent to something that takes it literally. On a 1/16-VAE model (Flux 2 is 128-channel, Qwen-Image 2.x is 64) it decodes at double the requested size: 1024 comes out 2048, at four times the VRAM.

Installing

ComfyUI Manager, search ComfyUI-HWP-Nodes, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/hwprinz/ComfyUI-HWP-Nodes

No models, no dependencies for this node. The pack's requirements.txt (qrcode, blind-watermark) exists only for the blind watermark on HWP Save Image (Advanced), and a clone won't install it:

cd ComfyUI/custom_nodes/ComfyUI-HWP-Nodes
python -m pip install -r requirements.txt

Search HWP to find the node. Version notes: it only exists from 0.9.8 (Sept 2026), and the model input arrived in 0.9.9 (Oct 2026) - missing socket means update.

Where people get burned

The ratio drifts, because it rounds up. SDXL, FLUX at 5:2 with factor 32 gives 1632×672 - 2.43:1, not 2.5:1. Invisible on a wallpaper; need the exact ratio, generate slightly wide and crop.

A preset is not a quality setting. 16K is a 126 MP budget, and an SDXL-family checkpoint will tile and duplicate anatomy long before that. The big presets are for pixel-space models and upscale passes - generate at native area, upscale after.

Ideogram 4 / 4.5 have a per-side cap. Their range is 256–2048 px per side with a 6:1 ceiling, so the Qwen2.1, Ideogram preset's 4.0 MP can't survive a wide shape - 5:2 would be 3264×1312, past 2048 wide. Drop to the SDXL, FLUX budget or accept a smaller output.

It knows VAE-safe, not trained-ratio. For SDXL it won't reproduce the buckets exactly - 1152×896 is a shade under the preset area, and the round-up shifts it again. Want that exact size, type it into Empty Latent Image; use this node for shapes not in the bucket list.

CategoryHWP

Inputs (6)

NameTypeDefaultDescription
model_typeCOMBOBase pixel budget (width × height at 1:1) plus the model family's max side — the aspect ratio only changes the shape, and extreme ratios get scaled down so the long side never exceeds the model's limit.
aspect_ratio_widthINT1Aspect ratio, width part (free integer, e.g. 5 for 5:2).
aspect_ratio_heightINT1Aspect ratio, height part (free integer, e.g. 2 for 5:2).
downscale_factorINT321–128Both dimensions are rounded UP to multiples of this — pick what the model's VAE/patch size requires (8: SD 1.5 / 2.1 / SDXL, 16: FLUX.1 / SD3 / Z-Image / Krea 2 / Qwen-Image 1.x, 32: Qwen-Image 2.x / GLM-Image / FLUX.2).
batch_sizeINT11–4096Batch size of the latent output (1–4096).
modeloptMODELOptional — the model the latent will be sampled with (same MODEL chain as your sampler). Connect it to get the latent in that model's native layout; needed for custom samplers (e.g. RES4LYF ClownsharKSampler) that do not rescale empty latents themselves.

Outputs (3)

NameTypeDescription
widthINT—
heightINT—
latentLATENT—