Guy Recommended Resolution Calculator and Latent Generator
Stop Typing 1536×1024 Into SDXL and Getting Melting Anatomy
- LATENT
- LATENT_WIDTH
- LATENT_HEIGHT
- CLIP_WIDTH
- CLIP_HEIGHT
- RESCALE_FACTOR
SDXL doesn't accept "whatever resolution you feel like." It was trained on exactly 41 fixed aspect ratios - 1024×1024 native, plus sizes like 1344×768, 1216×832, 1536×640 and their rotations - and it generates cleanly at those and mushily in between. That's the whole reason this node exists: you tell it the final image size you actually want, it snaps you to the nearest ratio SDXL was actually trained on, hands you a blank latent at that size, and tells you how much to upscale afterward. The name is long because the author gave up on brevity around the same place he gave up on capital letters, but the job is dead simple.
It's a resolution calculator pretending to be a latent node, and honestly that's a good trade. The standard "generate at native res, then hi-res fix" doctrine from the KB's upscaling essay is exactly what it automates: render at a trained ratio, then upscale to your target. People who skip that step and generate at off-ratio resolutions get stretched anatomy, tiling artifacts, and the classic "why is everyone a long-necked giraffe" post.
How it works
Under the hood there's a hardcoded table of the 41 ratios from the SDXL paper (arXiv 2307.01952, page 17). calc() computes the aspect ratio of your desiredWidth / desiredHeight, finds the table entry with the closest match, and calls ComfyUI's EmptyLatentImage to make a blank latent at that snapped size. Then:
RESCALE_FACTOR= your desired size divided by the snapped size, taken on the larger axis. Wire it into an upscale-by-factor node (likeUpscale Image ByorLatentUpscaleBy) to get from the base render to your target dimensions.CLIP_WIDTH/CLIP_HEIGHT= the snapped size ×clip_scale. That's the author's one real enhancement over the original script this is forked from (marhensa'ssdxl-recommended-res-calc).
The inputs that matter
Only two are worth touching:
desiredWidth/desiredHeight(default 1024×1024) - the final output size you're aiming for, not the generation size. This is the entire point.clip_scale(default 2.0) - SDXL conditions at double the latent resolution, so 1024×1024 latent gets a 2048×2048 CLIP conditioning. Leave it at 2 unless you know why you'd change it; it matches the SDXL convention ComfyUI's own EmptySDXL node uses.
batch_size just sets how many blank latents you generate, for batch workflows. All four sit in the required inputs and you set them on the node, not from upstream.
Outputs
LATENT (the blank tensor, wire into your KSampler), LATENT_WIDTH / LATENT_HEIGHT (the snapped generation size, handy if you want to show it), CLIP_WIDTH / CLIP_HEIGHT (for the conditioning, if you're building an SDXL workflow manually), and RESCALE_FACTOR (the number to feed your upscale node).
Install
No dependencies, no model downloads, no requirements.txt - the pack only imports EmptyLatentImage from ComfyUI core. Easiest path: ComfyUI Manager → search "guy-nodes-comfyui" and install (it's registered on the Comfy Registry under guyaton). Or clone it yourself:
cd ComfyUI/custom_nodes
git clone https://github.com/guyaton/guy-nodes-comfyui.git
Then restart ComfyUI. It lands in the utils category, searchable as "Guy Recommended Resolution Calculator and Latent Generator."
Where people get burned
The snap-to-nearest behavior means your final aspect ratio won't exactly match what you typed - the rescale factor is computed on the longer axis, so the other axis comes out a little short. This tripped people up with the original script on r/comfyui: the tool returns the closest SDXL ratio and the upscale to reach it, but "the final size might not be the same aspect ratio as the desired one." If pixel-exact output matters, this isn't the node; if "close enough, then crop" is fine, it's great.
It's also SDXL-only - it always snaps to SDXL's table, so don't feed it Flux or SD 1.5 workflows. And the desiredWidth/desiredHeight inputs allow 0 in the schema, but a zero height is a division-by-zero crash, so keep them at real sizes.
Honest verdict: for an SDXL beginner who keeps typing arbitrary resolutions and wondering why anatomy breaks, this is a nice autopilot. If you already know the 41 ratios by heart, you're not missing much - but you're also not the one who needs it.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| desiredWidth | INT | 10240–8192 | — |
| desiredHeight | INT | 10240–8192 | — |
| clip_scale | FLOAT | 2.01–10 | — |
| batch_size | INT | 11–64 | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |
| LATENT_WIDTH | INT | — |
| LATENT_HEIGHT | INT | — |
| CLIP_WIDTH | INT | — |
| CLIP_HEIGHT | INT | — |
| RESCALE_FACTOR | FLOAT | — |