Nodes/ComfyUI-Qais-Helper/QH: Size Swapper
ComfyUI Node

QH: Size Swapper

Flip a resolution to landscape or square without retyping it

By QaisMalkawi·Created 3 years ago·Updated 6 months ago· 2
QH: Size Swapper
    • Width
    • Height
    size1
    size2
    mode

    "QH: Size Swapper" takes two integers and rearranges them into a width and a height, depending on the mode you pick. That's the whole job, and it's the kind of node you don't appreciate until you're building a workflow that needs to generate the same thing in landscape, portrait, and square without manually retyping numbers in four different places.

    Think about what this actually buys you. ComfyUI's shared-workflow culture is all about parametric control - you want one knob that changes output shape, not a hardcoded size buried in an EmptyLatentImage. If a resolution node upstream produces a width and height (the pack's own SDXL Resolution node, for instance, spits out exactly those two INTs), Size Swapper lets you derive the rotated and square variants from the same pair. One source of truth for the aspect, three output shapes.

    How it works

    Three inputs:

    • size1 - INT
    • size2 - INT
    • mode - an enum with four choices: width x height, height x width, width x width, height x height.

    Two outputs:

    • Width - INT
    • Height - INT

    The modes map exactly onto what they sound like. width x height passes size1 and size2 straight through. height x width swaps them, which flips landscape to portrait. width x width and height x height repeat one of them twice, giving you a square at either dimension. The source is a four-branch if statement over the mode string - no math, no hidden logic. What you see is what you get.

    How you'd actually use it

    The natural chain: pick a resolution (SDXL Resolution node, or type a custom size), feed the two INTs into Size Swapper, and take the outputs into your EmptyLatentImage or sampler size slots. Wire a boolean-driven switch in front of it and you can toggle between portrait and landscape by flipping one condition. It's also handy when a node upstream hands you dimensions in one orientation and the consumer expects the other - a quick swap instead of retyping.

    Installing it

    Same trivial install as the rest of the pack - numpy-only, no model files, nothing to download:

    • ComfyUI Manager - search "ComfyUI-QaisHelper" and Install.
    • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/QaisMalkawi/ComfyUI-QaisHelper, then restart.

    It lives under "Qais Helper" as "QH: Size Swapper."

    The honest take

    This is the thinnest node in the pack after the boolean helpers, and it's not going to change your life. It has no notion of what a "correct" resolution is - it will happily hand you a width and height that are off-ratio for SDXL, so pair it with a resolution node that stays on trained aspect ratios. As a small piece of plumbing for parametric workflow builds, though, it's exactly the right kind of boring: predictable, type-safe (plain INTs, no wildcard weirdness), and it does one thing. If you build workflows to share or reuse, that's worth keeping around.

    CategoryQais Helper

    Inputs (3)

    NameTypeDefaultDescription
    size1INT
    size2INT
    modeCOMBO4 options: width x height, height x width, width x width, height x height

    Outputs (2)

    NameTypeDescription
    WidthINT
    HeightINT