Nodes/comfyui-jz/jz Resolution Selector
ComfyUI Node

jz Resolution Selector

The Resolution Selector You Can Actually Wire Into a Graph

By j-zhang19·Created about a month ago·Updated a day ago· 2
jz Resolution Selector
    • width
    • height
    aspect_ratio1:1
    modetable
    resolution1K
    megapixels1.0
    multiple8
    aspect_ratio_in

    Don't skip this because it sounds like a clone of ComfyUI's built-in node. jz Resolution Selector exists precisely because the core one has a hole: its aspect_ratio input is a COMBO, and ComfyUI refuses to connect a STRING output to a COMBO socket. If your aspect ratio comes from anywhere but your own hand on a dropdown - a calculated value, another node's output - the core node is a dead end. This fixes exactly that.

    Why you'd reach for it

    Most of the time you don't need a resolution node at all. You type 1024x1024 into an Empty Latent Image and move on. You need one when the dimensions shouldn't be a number you typed - the moment the target size depends on something else in the graph. In this pack's home turf that "something else" is jz Pad Calculator, which works out the exact size the Gemini image API can emit for an image you've fed it, outpainting-style. Its aspect_ratio output is a STRING, and the whole reason this node exists (read the source comment - it says so) is so you can wire that string straight into a node that turns it into usable width/height INTs. No manual retyping, no drift between what the API supports and what your latent is sized to.

    How it works

    This is a value node, not a pixel one - the plumbing layer of ComfyUI, where the job is fighting repetition and stale typed-in numbers. Pick an aspect ratio, get two integers out. Under the hood there are two ways to compute them, chosen by the mode widget:

    • table (default) looks the ratio up in a hardcoded dimension map - the same DIMENSION_MAP that jz Pad Calculator and jz Gemini Generate's dropdowns draw from, so they literally cannot disagree. Ten plain ratios (1:1 through 21:9, plus 5:4/4:5 that core's eight-ratio list doesn't even offer), each with a 1K, 2K, and 4K size. The resolution widget only matters here.
    • megapixels ignores the table and uses the core Resolution Selector's own formula: scale the ratio so the result hits your target megapixels, then round each side to a multiple of multiple (default 8, so everything stays latent-friendly). This mode handles any ratio and any target from 0.1 to 16 MP. megapixels and multiple only matter here.

    The two deliberately disagree: 16:9 at 1 MP is 1376x768 in the table but 1368x768 by the formula. If a downstream API is going to reject a size it doesn't know, use table. If you just need a sane, divisible resolution, megapixels is the flexible one.

    The inputs and outputs that matter

    • aspect_ratio - dropdown, defaults to 1:1, plain ratios only.
    • mode - table or megapixels; this is the one you actually think about.
    • aspect_ratio_in - the optional STRING socket that makes this node worth having. Wire it and it beats the dropdown. It'll even parse core's parenthesized form, so 16:9 (Widescreen) fed in still resolves.
    • Outputs are width and height, both INTs - wire them into an Empty Latent Image, jz Resize And Pad, or anything else that takes dimensions.

    One thing that bites: the widgets that don't apply to your chosen mode are just ignored, not hidden, so it's easy to think resolution matters when you're in megapixels mode. It doesn't.

    Installing it

    Install the pack once - every node in the jz/ category comes with it. ComfyUI Manager: search comfyui-jz. Or the manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/j-zhang19/comfyui-jz
    # restart ComfyUI
    

    No model files to download for this node, and no API key - the Gemini/OpenRouter nodes in this pack need keys, this one doesn't touch the network. The whole pack is tiny (declared deps are just requests, pillow, numpy).

    Common issues

    The pack auto-discovers every node in nodes/, and it loads all-or-nothing: if any file fails to import, the whole jz/ category vanishes. The shared dimension table lives in pad_calculator.py, which imports scipy and torch at module load - so if the pack's nodes don't show up on a lean install, a missing scipy is the usual culprit (pip install scipy in your ComfyUI Python env). And if you wire in a ratio table mode doesn't know, it raises a clear error telling you to switch to megapixels - read it, it lists the ten ratios that work.

    Honestly? If you hand-type every resolution anyway, the core node is fine and you don't need this. The day you build a workflow where the target size has to follow the input image - that's when the STRING socket earns its keep.

    Categoryjz/image

    Inputs (6)

    NameTypeDefaultDescription
    aspect_ratioCOMBO1:1plain ratios, no parenthesised names — wire jz Pad Calculator's aspect_ratio into aspect_ratio_in to drive this from a graph
    modeCOMBOtabletable = the exact dimensions Gemini emits; megapixels = core Resolution Selector's formula
    resolutionCOMBO1Ktable mode only
    megapixelsFLOAT1.00.1–16megapixels mode only — 1.0 MP is about 1024x1024 square
    multipleINT88–128megapixels mode only — each side is rounded to a multiple of this
    aspect_ratio_inoptSTRINGoverrides the dropdown when connected — e.g. jz Pad Calculator's aspect_ratio output

    Outputs (2)

    NameTypeDescription
    widthINT
    heightINT