CAS Empty Latent Aspect Ratio Axis
The ComfyUI node that does your aspect-ratio math for you
- LATENT
- width
- height
If you've ever sat in ComfyUI staring at an EmptyLatentImage widget, trying to work out what 16:9 is at a 768-wide base, this is the node that rescues you. CAS Empty Latent Aspect Ratio Axis is the "by axis" half of the CASNodes pack: you type one dimension, pick an aspect ratio from a dropdown, and it computes the matching dimension and hands you a ready-to-use empty latent. No mental arithmetic, no calculator tab, no accidentally feeding KSampler a width that isn't a multiple of 8.
What it actually does
Like ComfyUI's built-in EmptyLatentImage, this node outputs a blank latent that you wire into KSampler's latent input - it doesn't generate anything, it just sizes the canvas. The mechanism is a rounding calculation followed by a shape check, then it fills a zeroed tensor. The details matter because they're per-model, not universal.
That model dropdown sitting with the other widgets sets the latent spec: SD1.5 and SDXL use the classic 4-channel, 8×-downsampled VAE; Flux.1, Krea, and Qwen-Image use 16 channels at 8×; Flux.2 is the outlier at 128 channels and a 16× downsample (Black Forest Labs retrained its VAE from scratch). The node picks the right shape for whichever you select - which is exactly why selecting the wrong model silently hands you a latent of the wrong shape. Pick the model you're actually running in the sampler, not the one you wish you had.
The inputs that matter
- primary_dim (INT, default 512) - the one dimension you know. Below 8 it throws, so that's your hard floor.
- reference - "Width" or "Height", telling the node which one primary_dim is. Flip this and you get a portrait where you wanted a landscape, so check it before you queue.
- aspect_ratio - 13 presets from 1:1 Square out to 21:9 Widescreen, plus the portrait mirrors.
- batch_size (default 1) - how many blank latents to create in one go.
Outputs are the LATENT (into KSampler) plus the computed width and height as INTs - genuinely handy when another node in the graph needs to know the actual resolution you generated.
The one trap
The node insists dimensions are divisible by the model's stride (8 for most, 16 for Flux.2), and when your ratio and base dimension round onto something off-boundary, it raises a ValueError instead of quietly producing a latent. 16:9 at a 768 base lands on 768×432 and sails through; a less friendly combo will error out. The fix is a nudge - move primary_dim by a few pixels until the math lands on a multiple of 8. Annoying for two seconds, and it saves you from generating into a malformed latent.
Install
This node ships in a two-node pack that appears under the latent category. There are no model downloads and no heavy dependencies - it just builds a zeros tensor, so install is as painless as custom nodes get. Via ComfyUI Manager, search comfyui-aspect-ratio-presets and hit Install; or manually:
cd YOUR_COMFYUI/custom_nodes
git clone https://github.com/budihartono/comfyui-aspect-ratio-presets.git
Then restart ComfyUI. If you just need the curated sizes and don't care about computing them, the sibling CAS Empty Latent Aspect Ratio Preset node is the one you want - this one is for when you have one dimension fixed and want the rest done for you.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| primary_dim | INT | 512 | — |
| reference | COMBO | 2 options: Width, Height | |
| aspect_ratio | COMBO | 13 options: 1:1 Square, 3:2 Landscape, 2:3 Portrait, 4:3 Landscape, 3:4 Portrait, 16:9 Landscape, +7 | |
| batch_size | INT | 1 | — |
| model | COMBO | 6 options: Krea, Flux.2, Qwen-Image, Flux.1, SDXL, SD15 |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |
| width | INT | — |
| height | INT | — |