WK Latent Size
WK Latent Size — pick a megapixel count, not a pixel grid
- latent
- width
- height
- resolution
The name is the whole pitch: instead of typing a pixel grid into an empty-latent node, you pick how many megapixels you want and an aspect ratio, and this node does the arithmetic and hands you a latent that's ready to sample.
That's more than a convenience these days. Modern models don't train on one magic resolution anymore - they train on a megapixel band. Flux, Z-Image and friends are happy anywhere in roughly the 1–2MP range, and the failure mode is soft degradation rather than duplicated anatomy. So thinking "I want a 9:16 image, roughly 1 megapixel" is actually the more accurate mental model, and WKLatentSize lets you say exactly that instead of fiddling with 896×1408 vs 832×1216 until something looks right.
How it works
It takes your megapixel target and aspect ratio, solves for width and height so the pixel count lands in the right ballpark, and rounds each side to the nearest multiple of divisible_by. Then it builds a zero latent of shape [batch, 4, height/8, width/8] on the right device.
That /8 is the VAE's downsampling factor - a latent's pixel dimensions are always one-eighth of the final image. The divisible-by rounding exists precisely so that division stays exact and the sampler doesn't complain about a non-conformant size.
The inputs that matter
- megapixels - the target size, from 0.1 up to 2.5. For SDXL-era models, 1.0 at one of their trained ratios is the sweet spot; for the current crop of 1–2MP models, pick in the band and don't chase 2.5 unless you've confirmed your model tolerates it.
- aspect_ratio - 23 presets covering portrait and landscape: 1:1, 3:4, 2:3, 9:16, 16:9, 9:32, and friends. Pick the frame, not the pixels.
- divisible_by - 8/16/32/64, default 64. Leave it on 64. Flux requires multiples of 64, and the default already keeps you safe.
- batch_size - 1 to 4096, for generating multiple latents in one go.
- use_custom_ratio + custom_aspect_ratio - flip the boolean on and type any ratio like
16:9if a preset doesn't cover it.
The outputs
Four of them, and the last three are the reason to reach for this over the built-in Empty Latent Image:
- latent (LATENT) - wire this straight into your sampler.
- width / height (INT) - the resolved numbers, available as wires to drive other nodes.
- resolution (STRING) - a ready-made
"1024 × 1024"label you can route to a text/annotation node or a filename builder.
That's the real selling point: you get the latent and the dimensions in one shot, so a second branch that needs to know the size doesn't have to guess it.
Installing it
This node ships inside the ComfyUI-WorkspaceKit (WK) pack, so you're installing the whole workspace plugin to get it:
cd ComfyUI/custom_nodes
git clone https://github.com/ZiYao00/ComfyUI-WorkspaceKit.git
cd ComfyUI-WorkspaceKit
python -m pip install -r requirements.txt
Then restart ComfyUI. Or search WorkspaceKit in ComfyUI Manager and skip the terminal. The only Python dependency is send2trash, and there are no model downloads - it's a light pack.
Where people get burned
- Custom ratio format. It must be
width:heightwith positive numbers -16:9works,16x9throws an error. The error message tells you exactly that. - Chasing megapixels. The node caps out at 16384px per side, but you'll hit model quality limits long before that. 2.5MP on a model trained for 1MP gives you soft garbage, not more detail.
- The honest take. This is EmptyLatentImage with nicer input math and dimension wires bolted on. If you never use the
width/height/resolutionoutputs, the built-in node does the same job for free - don't install a whole workspace pack just for this. If you do want the dimensions, it's genuinely handy.
One more: the pack is public beta, and it moves real workflow files around. Back up your workflows and settings before using it in a primary environment.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| megapixels | COMBO | 1.0 | 15 options: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, +9 |
| aspect_ratio | COMBO | 1:1 | 23 options: 1:1, 3:4, 2:3, 3:5, 4:5, 5:7, +17 |
| divisible_by | COMBO | 64 | 4 options: 8, 16, 32, 64 |
| batch_size | INT | 11–4096 | — |
| use_custom_ratio | BOOLEAN | false | — |
| custom_aspect_ratio | STRING | 1:1 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | — |
| width | INT | — |
| height | INT | — |
| resolution | STRING | — |