Nodes/random_resolution_picker/Random Resolution Picker
ComfyUI Node

Random Resolution Picker

Stop babysitting the aspect ratio — roll a random resolution instead

By JakoError·Created 5 months ago·Updated 5 months ago· 1
Random Resolution Picker
    • width
    • height
    • label
    resolutions# Duplicate lines are weighted — list a size twice to double its probability. 1328,1328 1664,928 928,1664 1472,1104 1104,1472 1584,1056 1056,1584
    auto_randomizetrue
    seed0

    Generating at the same 1024x1024 square forever gets boring fast, and it's genuinely bad for exploring a model's range. Every architecture has native resolutions it was trained on - SDXL's 1152x896 and 1344x768 and friends, Flux's 1664x928-and-divisible-by-64 territory - and the fix for "everything looks the same" is often just changing the canvas, not the prompt. RandomResolutionPicker is a tiny node that rolls the dice on width and height for you, so every queue run hands your sampler a different canvas from a list you control.

    It does exactly one thing, and it does it with zero dependencies. Give it a multiline list of width,height pairs, wire the width and height outputs into an Empty Latent Image, and it picks one pair at random on every generation. If you're generating a batch, you get a spread of aspect ratios instead of fifty identical squares. It's also a nice cheap way to test whether a LoRA holds up across resolutions, or to shake loose variety when a checkpoint is clearly overfitted to one orientation.

    How it works

    The node is dead simple under the hood. It parses your text block line by line - blank lines and lines starting with # are skipped, everything else must be exactly width,height with positive integers. Duplicate lines aren't an error; they're a feature. List a size twice and it's twice as likely to win, so you can weight your favorites without any separate probability field.

    The randomness is the part worth understanding. When auto_randomize is on (the default), the node flags itself as always-changed, so ComfyUI re-executes it on every queue run - that's what makes a 10-image batch come out at ten different resolutions even though nothing else in your graph changed. Flip auto_randomize off and it uses seed instead, so a fixed seed gives you a deterministic pick you can reproduce.

    If a Save Image node is downstream, the pick gets written into the PNG metadata under a RandomResolutionPicker key with the resolution, its width/height, and the seed that produced it. Handy when you're digging through a big output folder trying to figure out which settings made the good one.

    The inputs and outputs that matter

    You'll set two things. resolutions is the whole game - a multiline box where each line is width,height and lines starting with # are comments. The default ships with sensible Flux/SDXL-friendly pairs like 1664,928, 1472,1104, and 1328,1328, so it works out of the box. auto_randomize just toggles between "new pick every run" and "respect the seed."

    Outputs are three: width and height (both INT, wired into Empty Latent Image's width/height) and label (a STRING like 1664x928, handy if you're logging or building a filename).

    Installing it

    Easiest route: ComfyUI Manager → install via the search for random_resolution_picker by JakoError. Or the manual way:

    cd ComfyUI/custom_nodes
    git clone https://github.com/JakoError/random_resolution_picker
    

    Restart ComfyUI. That's it - the whole pack is one Python file using only the standard library. No requirements.txt, no model downloads, no GPU footprint of its own.

    Where people get burned

    The most common stumble is a malformed line. Type 1664x928 instead of 1664,928 (or leave a trailing comma) and the node raises a ValueError that names the offending line number - usually you've got a typo in your list, not a ComfyUI problem. The error text is actually pretty good at telling you which line is wrong.

    Second gotcha: the node does not validate that your picks are multiples of 64. Flux-class models are picky about that, so if you add exotic sizes to the list, sanity-check they're divisible by 64 before you queue a big batch and get a wall of tiled garbage.

    And remember - with auto_randomize on, every queue run is a new roll. If you're queuing the same workflow 20 times expecting identical outputs, you're not going to get them. That's the point, but it's also the thing that confuses people the first time they batch.

    Categoryimage/resolution

    Inputs (3)

    NameTypeDefaultDescription
    resolutionsSTRING# Duplicate lines are weighted — list a size twice to double its probability. 1328,1328 1664,928 928,1664 1472,1104 1104,1472 1584,1056 1056,1584
    auto_randomizeBOOLEANtrue
    seedINT00–2147483647

    Outputs (3)

    NameTypeDescription
    widthINT
    heightINT
    labelSTRING