Nodes/ComfyUI Text Processor/Advanced Resolution Selector
ComfyUI Node

Advanced Resolution Selector

Pick a ratio, get aligned pixel dimensions back — the deterministic resolution planner

By rookiestar28·Created 10 months ago·Updated 18 days ago· 16
Advanced Resolution Selector
    • width
    • height
    • resolved_aspect_ratio
    • resolved_direction
    • actual_megapixels
    • pixel_error_percent
    • aspect_error_percent
    output_modefixed
    aspect_ratio1:1
    directionlandscape
    custom_ratio_width1
    custom_ratio_height1
    megapixels1.0
    multiple8
    seed0

    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 pick custom, 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/height into EmptyLatentImage (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:9 is gone from the menu and from the random pools. Old workflows that stored it still execute in fixed/randomize mode - but you can't pick it anymore, and randomize_ratio deliberately excludes 1:1, custom, and the legacy 21:9.
    • Random modes override your selections - randomize and randomize_all replace the direction, and randomize_all / randomize_ratio replace 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.

    CategoryComfyUI Text Processor/Image

    Inputs (8)

    NameTypeDefaultDescription
    output_modeCOMBOfixedSelect fixed, seeded direction randomization, seeded preset and direction randomization, or seeded ratio randomization with the selected direction.
    aspect_ratioCOMBO1:1Choose one canonical ratio or provide a positive custom ratio pair.
    directionCOMBOlandscapeChoose the resolved orientation; randomize and randomize_all may replace it, while fixed and randomize_ratio preserve it.
    custom_ratio_widthINT11–10000Positive custom ratio width; used when aspect_ratio is custom.
    custom_ratio_heightINT11–10000Positive custom ratio height; used when aspect_ratio is custom.
    megapixelsFLOAT1.00.1–16Binary 1024 squared pixel budget before multiple alignment.
    multipleINT88–128Align both dimensions to this positive multiple.
    seedINT00–4294967295Explicit uint32 seed for deterministic randomized modes.

    Outputs (7)

    NameTypeDescription
    widthINTAligned output width in pixels.
    heightINTAligned output height in pixels.
    resolved_aspect_ratioSTRINGCanonical or reduced custom ratio label before direction is reported separately.
    resolved_directionSTRINGResolved landscape or portrait direction.
    actual_megapixelsFLOATRealized binary megapixels after multiple alignment.
    pixel_error_percentFLOATSigned realized pixel-area error percentage.
    aspect_error_percentFLOATSigned realized aspect-ratio error percentage.