Advanced Resolution Selector
Pick a ratio, get aligned pixel dimensions back — the deterministic resolution planner
- width
- height
- resolved_aspect_ratio
- resolved_direction
- actual_megapixels
- pixel_error_percent
- aspect_error_percent
Advanced Resolution Selector is the ComfyUI Text Processor node for when you want a resolution, not an image. It takes an aspect ratio, a direction, a megapixel budget, and an alignment multiple, and hands back exact pixel dimensions plus diagnostics - the numbers you feed into an EmptyLatentImage or a latent-size-aware sampler. It never touches a tensor; there's no IMAGE or LATENT anywhere in its outputs. If you came here expecting a generator, that's the first thing to know: this is the planning stage, and it's very good at its one job.
Why you'd reach for it: you're doing automated or batched generation and you want the same base resolution semantics across runs - generate at a sensible aspect ratio, aligned to a multiple your model or VAE likes, and reproduce it exactly. The KB's resolution lore says modern models take a megapixel band rather than a fixed size (SDXL's trained ratios, Flux needing multiples of 64, the 1MP–2MP band of Z-Image and Flux 2 Klein). This node is the practical version of that: pick a band, get clean aligned dimensions. It's a separate V1 node from Core's native Resolution Selector, so adding it doesn't disturb existing Core workflows or node IDs.
How it works
The ratio menu holds one canonical landscape entry per ratio: 1:1, 9:7, 4:3, 19:13, 3:2, 7:4, 16:9, plus custom. Portrait is produced by transposing the ratio - so there are no separate "portrait 3:2" menu entries to scroll past. Custom pairs get reduced to their canonical form by gcd: type 6:4 and it reports 3:2.
megapixels uses a binary 1024 × 1024 unit (0.1 to 16.0), and multiple aligns both dimensions to a step from 8 to 128 (in steps of 4). The core does a bounded candidate search that balances area error against aspect error, so alignment can make the realized size differ slightly from the target - that's what the diagnostic outputs exist for.
The seeded random modes are genuinely deterministic: an isolated random.Random(seed) stream, so identical serialized inputs give identical results, and it doesn't touch Python's global RNG (or the process-global random state other nodes might rely on).
The inputs that matter
output_mode- the decision that drives everything:fixed- selected ratio and direction, no randomness.randomize- seeded random direction, ratio preserved.randomize_all- seeded random ratio and direction.randomize_ratio- seeded random ratio from the non-square presets, direction preserved.
aspect_ratio,direction- the fixed half.custom_ratio_width/custom_ratio_height(1–10,000) appear when you pickcustom, and note they're validated in every mode even when a random mode won't use them.megapixels,multiple,seed- the budget, the alignment, and a normal uint32 seed with ComfyUI's queue control.
The seven outputs, in order: width, height, resolved_aspect_ratio, resolved_direction, actual_megapixels, pixel_error_percent, and aspect_error_percent. Wire the first two into your latent-size node; the error percentages tell you when alignment pushed you off target. A fresh execution also labels the width/height ports (width: N / height: N) via an optional frontend extension - cosmetic, not persisted, ignore it.
Install
Same pack, same path as the rest of ComfyUI Text Processor. ComfyUI Manager → search ComfyUI Text Processor → install → restart, or:
cd ComfyUI/custom_nodes/
git clone https://github.com/rookiestar28/ComfyUI_Text_Processor.git
pip install -r requirements.txt
No model downloads, no heavy deps - just the pack's simpleeval, requests, beautifulsoup4. Needs Python 3.10+ and ComfyUI Core 0.22.3+.
Where people get burned
- It doesn't generate. Feed
width/heightintoEmptyLatentImage(or your sampler's latent input); the output is a coordinate, not pixels. - Alignment drifts. A coarse
multiple(say 128) can land you at +3% area error and ~+5% aspect error versus the target - read the diagnostics instead of assuming the numbers are exact. The README's own example: 7:4, 1.0 MP, multiple 128 →1408 × 768, 1.03125 actual MP. 21:9is gone from the menu and from the random pools. Old workflows that stored it still execute infixed/randomizemode - but you can't pick it anymore, andrandomize_ratiodeliberately excludes1:1,custom, and the legacy21:9.- Random modes override your selections -
randomizeandrandomize_allreplace the direction, andrandomize_all/randomize_ratioreplace the ratio. If a run "ignores" your ratio, that's the mode doing its job.
For a quick sanity check: fixed, 16:9, landscape, 1.0 MP, multiple 8 gives 1368 × 768. If that's not what you get, you're on an older pack version - update and restart.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| output_mode | COMBO | fixed | Select fixed, seeded direction randomization, seeded preset and direction randomization, or seeded ratio randomization with the selected direction. |
| aspect_ratio | COMBO | 1:1 | Choose one canonical ratio or provide a positive custom ratio pair. |
| direction | COMBO | landscape | Choose the resolved orientation; randomize and randomize_all may replace it, while fixed and randomize_ratio preserve it. |
| custom_ratio_width | INT | 11–10000 | Positive custom ratio width; used when aspect_ratio is custom. |
| custom_ratio_height | INT | 11–10000 | Positive custom ratio height; used when aspect_ratio is custom. |
| megapixels | FLOAT | 1.00.1–16 | Binary 1024 squared pixel budget before multiple alignment. |
| multiple | INT | 88–128 | Align both dimensions to this positive multiple. |
| seed | INT | 00–4294967295 | Explicit uint32 seed for deterministic randomized modes. |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| width | INT | Aligned output width in pixels. |
| height | INT | Aligned output height in pixels. |
| resolved_aspect_ratio | STRING | Canonical or reduced custom ratio label before direction is reported separately. |
| resolved_direction | STRING | Resolved landscape or portrait direction. |
| actual_megapixels | FLOAT | Realized binary megapixels after multiple alignment. |
| pixel_error_percent | FLOAT | Signed realized pixel-area error percentage. |
| aspect_error_percent | FLOAT | Signed realized aspect-ratio error percentage. |