Nodes/Y7Nodes for ComfyUI/Y7 Dual Resolution Selector
ComfyUI Node

Y7 Dual Resolution Selector

Two sizes from one aspect ratio — the node that keeps your hires pass honest

By yushan777·Created 2 years ago·Updated 6 days ago· 10
Y7 Dual Resolution Selector
    • base_width
    • base_height
    • final_width
    • final_height
    ◄aspect_ratio1:1►
    ◄base_megapixels1.0►
    ◄final_megapixels2.0►
    ◄multiple16►

    The oldest trick in this hobby is still the best one: sample small, finish big. Generate at a resolution the card can chew through, then do a second pass at higher resolution so the model spends its attention adding detail rather than inventing composition. Hires fix, whatever the UI calls it.

    The awkward part is the bookkeeping. You pick one aspect ratio, then you need two sets of numbers for it - and the moment you edit one by hand, the second pass is subtly cropped, or the ratio drifts by a hair, or you're generating at 1025 pixels wide because a slider moved once. Y7 Dual Resolution Selector exists so that can't happen: one aspect ratio, two megapixel budgets, four integers.

    It's built for this pack's Krea 2 Two- and Three-Stage Samplers, where a single node does the small-then-large thing internally. Those samplers take the final size as a widget pair, so you need to hand them a resolution without retyping it.

    How it works

    One megapixel means 1024×1024 worth of pixels. From there it's school trigonometry: take the target pixel count, divide by the aspect ratio's w × h, square-root that, multiply back out by each side of the ratio. Then each axis is snapped to the nearest multiple of multiple, with a floor of one multiple so you can't ask for a zero-pixel dimension.

    Concretely, with the default multiple of 16:

    | aspect_ratio | base_megapixels 1.0 | final_megapixels 2.0 | | --- | --- | --- | | 1:1 | 1024×1024 | 1456×1456 | | 16:9 | 1360×768 | 1936×1088 | | 2.35:1 | 1568×672 | 2224×944 | | 3:4 | 880×1184 | 1248×1680 |

    The aspect list is the eleven you'd actually use - 1:1, 4:5, 5:4, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9, 2.35:1, 21:9 - not the long tail of weird ones some pickers ship.

    The four inputs and the four outputs

    You'll set base_megapixels (0.1–16, default 1.0) and final_megapixels (0.1–16, default 2.0) and then genuinely stop touching them. aspect_ratio is the creative choice, multiple (8–128 in steps of 8, default 16) is the safety rail.

    Wire the outputs like this:

    • base_width / base_height → Empty Latent Image (or whatever latent you're starting from), and also into the width / height widgets on Y7 Krea 2 Raw Sampling Shift if you're using it. The shift node can't read your latent - it wants numbers, and these are the right numbers.
    • final_width / final_height → the final_width / final_height inputs on the Two- or Three-Stage Sampler, which is where the latent gets resized at the handoff.

    There are no other inputs, no mask, no side effects. It's four integers and no opinion about what you do with them.

    A short install note

    ComfyUI Manager → Custom Nodes Manager → search Y7 or Y7Nodes → Install → restart. Or:

    cd /path/to/ComfyUI/custom_nodes
    git clone https://github.com/yushan777/ComfyUI-Y7Nodes
    pip install -r ComfyUI-Y7Nodes/requirements.txt
    

    then restart. The pack's two Python dependencies (color-matcher, opencv-python-headless) belong to the colour-matching and edit-alignment nodes, not this one - this node is pure math. And it's written in ComfyUI's V3 node API, so on a truly old ComfyUI it just won't show up in the node list; update first.

    Where people get burned

    The megapixels are total pixels, not a multiplier. Going from base_megapixels 1.0 to final_megapixels 2.0 is a 1.41× scale, not 2×. People who assume 2.0 means "twice as wide" get a surprise that looks like the node ignoring them.

    Rounding is per axis, so you land near the target, not on it. 2.0 MP at 16:9 comes out 1936×1088 - 2.1 MP. That's fine and intended; models care about the band, not the exact count. Just don't build a maths argument on the output.

    Nothing happens until you wire the final pair somewhere. The outputs are inert integers. If you set final_megapixels to 3.0 and the image is still small, the sampler that consumes it either isn't connected or has its own final_width / final_height sitting at 0 - which disables the resize entirely.

    Don't feed base_* to the empty latent and then something else to the sampler. Stage 1's resolution and the latent you actually sample have to be the same size, or the shift calculation and the resize ratio downstream are both working from the wrong number.

    One more: multiple 8 is fine for Krea 2 (its VAE works on an 8-pixel grid), and 16 is the safer default once a latent gets resized mid-run, because halving a non-multiple dimension at the latent level produces off-by-one crops that show up as a soft edge nobody can explain.

    CategoryY7Nodes/Utils

    Inputs (4)

    NameTypeDefaultDescription
    aspect_ratioCOMBO1:111 options: 1:1, 4:5, 5:4, 2:3, 3:2, 3:4, +5
    base_megapixelsFLOAT1.00.1–16—
    final_megapixelsFLOAT2.00.1–16—
    multipleINT168–128—

    Outputs (4)

    NameTypeDescription
    base_widthINT—
    base_heightINT—
    final_widthINT—
    final_heightINT—