Free Resolution Selector (custom ratio)
5 or 21:9 Instead of Picking From Eight Presets
- LATENT
- width
- height
The problem: you want 1536x640 and the dropdown doesn't have it
ComfyUI core's Resolution Selector is a good node with an annoying limitation: the aspect ratio is a dropdown of eight presets (1:1, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9, 21:9). Want 7:5, 16:10, or a ratio you worked off a reference image? You're back to Empty Latent Image, typing two numbers by hand and redoing the arithmetic every time you change megapixel count.
Free Resolution Selector does the arithmetic for you. Two integer fields, a target in megapixels, and it hands you the numbers and the empty latent.
How it works
You give it ratio_width and ratio_height (defaults 16 and 10), a megapixel target (default 1.0, range 0.1–16), and a multiple to snap to (default 8, range 8–128). It scales your ratio up to the target area - scale = sqrt(megapixels * 1e6 / (ratio_width * ratio_height)) - rounds width and height independently to your multiple, then builds a zeros latent an eighth that size:
torch.zeros([1, 16, height // 8, width // 8])
A 16:10 target at 1 megapixel lands on 1264 x 792; 21:9 at 1 MP gives 1528 x 656. The frontend script hides the ratio fields and replaces them with a single W ↔ H row plus a swap button, and a live line reading 1264 x 792 (1.0 MP). That second figure matters: rounding each side separately means 1.0 MP usually comes out 1.00–1.01 MP.
Note the units difference from core: it multiplies megapixels by 1024 * 1024, so its 1.0 MP square is 1024x1024, while a 1:1 here is 1000x1000.
The inputs and outputs that matter
megapixel is the one you'll set most - treat it as your budget. Current models are happiest in a 1–2 MP band, and generating small then upscaling still wins.
multiple is the one beginners skip and then wonder about. 8 is fine for anything on an 8x VAE, which is most things; if your model is fussy about divisibility, push it to 16 or 64. The field goes to 128 for exactly this reason.
ratio_width / ratio_height are plain integers up to 1000, so 21:9 is 21 and 9. Landscape versus portrait is just which field gets the bigger number - or hit the swap button.
Three outputs. LATENT goes into your KSampler's latent_image, same as an Empty Latent Image. width and height come out as real INTs, which is the part I actually reach for: wire them into whatever downstream node wants pixel dimensions - an upscale, a crop-and-stitch - instead of retyping numbers that can drift out of sync with the latent. And since the latent is always torch.zeros([1, ...]), there's no batch size input; for a batch, drop a Repeat Latent Batch after it.
Why a 16-channel latent is fine on a 4-channel model
The latent comes out 16-channel, because that's what the current generation of models uses. So why does it work when you plug an SDXL checkpoint into the same graph? comfy.sample.fix_empty_latent_channels, which runs inside common_ksampler: if the latent is entirely zero and its channel count doesn't match the model's latent_format.latent_channels, ComfyUI re-tiles it along the channel dimension. Zero is zero, so nothing is lost - which is why the author can reasonably claim it's tested with Anima, Flux 2, Krea 2 and SDXL.
The catch is in the condition: that reconciliation only applies to an untouched, all-zeros latent. Start writing real values upstream - an encode, a latent blend - and you're on your own.
Install
ComfyUI Manager → search X4Lch3mist → install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/X4Lch3mist/ComfyUI-X4Lch3mist.git
No Python dependencies: the pack's pyproject.toml declares an empty dependency list and the node imports only math and torch. GPL-3.0, category X4Lch3mist.
Common issues
You see four separate widgets and no preview. The merged row, the live readout and the swap button are a frontend extension in the pack's web/ folder. If the JS didn't load - usually a stale browser tab after installing - you get the plain fields and the node still computes fine. Hard-refresh; if it persists, check the folder is named exactly ComfyUI-X4Lch3mist, since a rename is the usual reason web extensions don't register.
It won't save you from the training ratio. This is a calculator, not a model-aware advisor - it will happily give you 1920x1080. SDXL's trained ratios are 1024x1024, 1152x896, 1216x832, 1344x768 and 1536x640, and going well outside them is how you get stretched bodies and doubled heads. What you gain here is hitting 7:4 exactly, at the megapixel count you want, without a calculator.
The numbers look a pixel or two off. That's the rounding, not a bug - each side can sit up to half a multiple from the ideal.
Verdict
A small node that does one thing properly, and what it does well is exactness: any ratio, a real megapixel target, and width/height as wires. Against core's Resolution Selector you gain free-form ratios and a latent output; you lose eight curated presets that quietly remind you what your model was trained on. Generate at fixed, safe resolutions forever and the dropdown is the better guardrail. For posters, banners, 21:9 framing, or anything where the composition dictates the ratio, keep this one.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| megapixel | FLOAT | 1.00.1–16 | — |
| multiple | INT | 88–128 | — |
| ratio_width | INT | 161–1000 | — |
| ratio_height | INT | 101–1000 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |
| width | INT | — |
| height | INT | — |