Nodes/ComfyUI-Random-Resolution/Random Resolution Selector
ComfyUI Node

Random Resolution Selector

Test landscape, portrait, and square from one prompt

By fudosanit·Created 9 months ago·Updated 9 months ago· 0
Random Resolution Selector
    • width
    • height
    • display
    height896
    width1152
    random_toggletrue
    seed0
    seed_behaviorrandomize

    It doesn't generate anything. Random Resolution Selector is a tiny math node from fudosanit/ComfyUI-Random-Resolution that takes one base width/height and hands back either the original, the swapped (portrait↔landscape) version, or a square - chosen at random (or not). That's the whole job, and it's exactly the job you want when you're staring at a prompt and wondering whether it reads better wide, tall, or square.

    People do this manually all the time: queue a batch, edit the Empty Latent Image dimensions between runs, squint at the results. This node automates the fiddly part. The author's framing - "test the same prompt as vertical, horizontal, and square compositions in one go" - is the whole pitch, and it's a legitimately useful one for character design, thumbnails, and anything where composition is the variable you're testing.

    How it works

    The mechanism is plain arithmetic, and since it's a custom/resolution node that runs entirely on CPU with the Python standard library (random, time), there's no GPU cost, no model files, no dependencies. The behavior is fully deterministic once you know the seed, which makes it predictable in a way that's worth understanding before you trust it blindly:

    • random_toggle on: the seed picks a mode via seed % 3 - 0 = original, 1 = swapped (width and height trade places), 2 = square (both set to (height + width) / 2).
    • random_toggle off: always outputs the original pair. The seed is ignored.

    The inputs that matter

    • width / height (defaults 1152 × 896, min 1) - your base composition. Those defaults are SDXL-flavored landscape; if you run SD 1.5 or Flux, set them to something your model actually likes, because randomizing away from the model's trained resolution is how you get soft, mushy results.
    • random_toggle (default on) - the master switch. Off = boring, on = the point of the node.
    • seed_behavior (fixed / randomize / increment, default randomize) - decides what happens to the seed. randomize draws a fresh random seed per run (your seed input is ignored). fixed uses your seed as-is. increment adds 1 to a shared counter every run.

    Here's the subtle bit that will bite you: with random_toggle on, one run shows you one mode, not all three. randomize just picks a random mode each time. To actually test the trio, set seed_behavior to fixed and queue seeds 0, 1, 2 - that walks you through original, swapped, square in order, guaranteed.

    Wiring the outputs

    Three outputs: width (INT) and height (INT) feed straight into whatever creates your latent - Empty Latent Image for SD-family models, or the equivalent latent-size node for newer architectures. display (STRING) is a human-readable line like width: 1152, height: 896 (seed: 123, mode: original) - pipe it into a text display node if you want to see which mode ran, or just watch it in the node's own widget preview.

    Installing it

    No models, no requirements.txt, nothing heavy. Either search "Random Resolution" in ComfyUI Manager, or:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/fudosanit/ComfyUI-Random-Resolution.git
    

    Restart ComfyUI and it's under the custom/resolution category.

    Gotchas

    • The increment counter is global - a class-level variable that persists for the whole ComfyUI process and is shared across every instance of the node. Two selectors in one graph step on each other's seeds. Use fixed or randomize unless you have one and only one of these in your workflow.
    • Feed it even numbers. The square mode averages the two dimensions; with odd inputs you'll get non-multiple-of-8 latents, which most models handle poorly or not at all. The defaults (1152 + 896 → 1024) land cleanly, but garbage in, garbage out.
    • Random resolution is a nice exploration tool, not a free lunch. Models are trained on specific aspect ratios, and the more you drift from them, the more anatomy and detail suffer. Keep your base pair inside your model's sweet spot and let the swap/square variants do the wandering.

    For a one-function node it's well-behaved and has exactly one job - which is more than you can say for a lot of micro-packs. If you batch-test compositions regularly, it earns its place next to Impact Pack and rgthree in the "actually useful QoL" drawer.

    Categorycustom/resolution

    Inputs (5)

    NameTypeDefaultDescription
    heightINT896
    widthINT1152
    random_toggleBOOLEANtrue
    seedINT0
    seed_behaviorCOMBOrandomize3 options: fixed, randomize, increment

    Outputs (3)

    NameTypeDescription
    widthINT
    heightINT
    displaySTRING