h4 - Latent Selector
Stop doing resolution math in your head
- LATENT
- WIDTH
- HEIGHT
Every ComfyUI workflow starts the same way: an Empty Latent node where you type width and height and pray they're not going to make the sampler explode. The h4 - Latent Selector is that node with a brain. Pick your base model and an aspect ratio, and it does the resolution math for you - then hands you the actual numbers so the rest of your graph can use them.
It lives in the h4_Live pack, a big "stateful, loop-friendly utility belt" from an author who goes by h4. This particular node is one of the calmer pieces of the toolkit: no state, no loops, just a sensible resolution generator.
How it works
The node picks a target pixel area from your base_model - SD1.5 gets 512×512 worth of pixels (262,144), SDXL gets 1024×1024's worth (1,048,576), and Wan/Z-Image gets the 1280×720 ballpark. Then it applies your chosen aspect ratio as a multiplier: 16:9 stretches the area wide, 9:16 makes it tall, 21:9 goes ultrawide, and so on. Anything you type into custom_width/custom_height gets snapped to a multiple of 16, because that's what the hardware and the samplers actually like.
That gives you a big empty latent batch, ready to feed a KSampler - same as ComfyUI's built-in Empty Latent, except you chose "3:2 classic landscape" instead of doing long division.
The inputs that matter
base_model- the architecture you're generating on. SD1.5, SDXL, Flux, Wan/Z-Image, or "Start From Custom" to ignore the presets entirely. Flux's best-guess area is the SDXL one, which is about right for default-scale output.aspect_ratio- 12 options from 1:1 square up to 21:9, plus "Custom Dimensions."batch_size- how many identical empty latents to generate. 1 for a single image, more if you've got the VRAM and want parallel variations.custom_width/custom_height- only read when you've picked a custom mode.
The output you'll actually use
Besides the LATENT (into your sampler), it also emits WIDTH and HEIGHT as plain integers. That's the sleeper feature: wire those into anything that wants the canvas size - an image resize, a save node's metadata, a text formatter - and your whole workflow agrees on dimensions without you restating them. One source of truth, fanned out.
Installing it
This node ships inside h4_Live, so you install the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/m3rr/h4_Live
# then restart ComfyUI
Or via ComfyUI Manager - search "h4_Live" and install from the list. The pack declares zero Python dependencies, so there's nothing extra to pip install; it runs on what ComfyUI already bundles.
Where it can bite you
The presets are best-effort, not gospel. If you're generating SDXL and the image looks cramped, remember the aspect multiplier targets total pixel area, so a 21:9 SDXL image ends up wide but with fewer pixels per side than the square default. And if you set a custom dimension that isn't a multiple of 16, the node silently nudges it - type 1037 and you'll get 1040, so glance at the output before you assume the image is exactly what you asked for.
Honestly? If you only ever generate one size, the stock Empty Latent plus a calculator is fine. The Latent Selector earns its keep the moment you switch base models or aspect ratios often - that's when not re-typing resolutions stops being a convenience and starts being the difference between "oh nice" and "why is this 768 pixels wide."
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| base_model | COMBO | SDXL | Which model architecture are you using? This determines the optimal pixel area. SD1.5 uses 512px base, SDXL uses 1024px, Wan uses 720p. Pick 'Start From Custom' to ignore presets and use your own width/height. |
| aspect_ratio | COMBO | 1:1 (Square) | The shape of your canvas. 1:1 = perfect square (great for avatars). 16:9 = widescreen cinema. 9:16 = phone wallpaper / story format. Pick 'Custom Dimensions' to manually set width and height below. |
| batch_size | INT | 11–64 | How many identical empty latents to generate in one batch. Set to 1 for single images. Crank it up if you have the VRAM and want to generate multiple variations in parallel. |
| custom_widthopt | INT | 102464–16384 | Manual width override (only used when 'Start From Custom' or 'Custom Dimensions' is selected). Values get snapped to the nearest multiple of 16 for hardware compatibility. |
| custom_heightopt | INT | 102464–16384 | Manual height override (only used when 'Start From Custom' or 'Custom Dimensions' is selected). Values get snapped to the nearest multiple of 16 for hardware compatibility. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |
| WIDTH | INT | — |
| HEIGHT | INT | — |