Resolution Selector (Real MP)
Stop memorizing aspect ratios — tell this node your megapixel budget and let it do the math
- width
- height
- megapixels
- label
Every few weeks you end up back in the same place: you want a landscape image, you know roughly how much VRAM you're willing to spend, and you're typing "SDXL 16:9 resolution" into a search box for the fifth time. This node kills that whole ritual. Set a megapixel budget, an aspect ratio, and a snap multiple - it returns the closest usable width/height plus a matching empty latent, all at once.
It's a one-trick utility under utils/resolution from speedyrulz/comfyui-resolution-selector, and the trick is exactly the convention the community converged on years ago: modern diffusion models are trained in a megapixel band, not at a handful of fixed sizes. SDXL targets roughly 1 MP rounded to multiples of 64; Flux wants the same idea but stricter about divisibility. You shouldn't be memorizing 1344x768 - you should be saying "1 megapixel, 16:9" and letting something pick the grid point.
How it works
The core is a tiny search, not a lookup table. Given your megapixels, ratio, and multiple, it walks the four grid points around the ideal dimensions and picks the one that minimizes a combined score of pixel-count error and log-ratio error. So 1.05 MP at 1:1 with multiple 32 lands on exactly 1024x1024; 4.15 MP at 16:9 with multiple 64 lands on 2688x1536. Nothing below multiple per edge, and edges are always on the grid - which is the entire point.
You get four outputs. The latent is a fresh empty tensor at the chosen size divided by 8 per side (that's the VAE's 8x downsampling). width and height are plain INTs you can wire into anything. The fourth, image, is optional resizing: if you feed an image in with use_image on, it's lanczos-rescaled to cover the target then center-cropped to fit exactly - handy for img2img where you want the source pre-sized to the sampling resolution.
The inputs that matter
Most of the seven widgets you can leave alone, but these are the ones you'll actually touch:
- megapixels - your budget, e.g.
4.15. The default1.05is basically "SDXL square" territory. - aspect_width / aspect_height - ratio terms like 16 and 9.
- multiple - the snap grid. Default 32 is fine for SDXL; crank it to 64 for Flux, which wants 64-divisible dimensions.
- latent_type - this is the one that bites people.
SD / SDXLmakes a 4-channel latent,Flux / SD3makes 16 channels. The default is Flux/SD3, so if you're on SDXL and never touch this, you'll feed a 16-channel latent into an SDXL sampler and get a cryptic shape error.
The use_image_ratio toggle makes the node ignore the ratio widgets and read the aspect from your connected image instead - nice when you're working "same ratio as the reference."
Install
It's a tiny pack: one node, one JS file, zero model downloads, zero extra dependencies beyond what ComfyUI already ships. Easiest path is ComfyUI Manager - search "comfyui-resolution-selector" and hit install. Or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/speedyrulz/comfyui-resolution-selector
Then restart ComfyUI. One extra step here: hard-refresh the browser tab (Ctrl+Shift+R). The live resolution preview at the bottom of the node is a frontend script, and a stale page won't load it.
Gotchas worth knowing
The image output returns None when no image is connected or use_image is off. The README says it plainly: don't leave that socket wired up in that case, or whatever it feeds will choke on nothing.
If you use an image's ratio, the preview can't show you the final dimensions ahead of time - the node's own display switches to "resolved at runtime," because the image dimensions only exist once the workflow runs. That's expected, not a bug.
And the subtle one: multiple below 8 silently breaks exact latent matching, because the latent is size/8 and rounds down. Keep it at 8 minimum; you're almost always at 32 or 64 anyway.
The take
For a "type two numbers, get a latent" utility it's refreshingly competent - the live preview, the image cover-and-crop, and the Flux/SD3 latent switch are all things bigger packs get wrong. If you only ever generate at three saved resolutions, this is overkill; a text switcher over a few Empty Latent Image nodes does the same job. But the moment you're iterating ratios, sharing workflows where the receiver should just set their own MP budget, or running img2img against mismatched sources, this earns its slot. It's the kind of small, sharp node you forget is there - until you're looking up aspect ratios for the sixth time.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| aspect_ratio | COMBO | 16:9 (Widescreen) | Aspect ratio of the output. Portrait entries are listed before their landscape counterparts. |
| megapixels | FLOAT | 1.000.01–64 | Target area in real megapixels: 1.0 = 1,000,000 pixels. Note this is NOT the built-in Resolution Selector's unit, which is 1024x1024 = 1.049 MP. |
| alignment | INT | 161–256 | Pixel grid both axes must land on = VAE spatial downscale x DiT patch size. 16: Krea 2 / Flux / SD3 / Qwen-Image / Wan. 32: MiniMax H3. 64: SDXL / SD1.5, and universally safe. Getting this wrong causes a band of artifacts along the bottom/right edge. |
| exact_ratio | BOOLEAN | true | On: hold the aspect ratio exactly by snapping to the lattice of valid sizes, accepting a slightly different area. Off: round each axis independently, hitting the area target more closely but drifting the ratio. |
| custom_w | INT | 161–4096 | Width term of the ratio, used only when aspect_ratio is Custom. |
| custom_h | INT | 91–4096 | Height term of the ratio, used only when aspect_ratio is Custom. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| width | INT | Width in pixels, a multiple of alignment. |
| height | INT | Height in pixels, a multiple of alignment. |
| megapixels | FLOAT | Real megapixels actually produced. |
| label | STRING | Dimensions as "1152x2048", handy for filename prefixes. |