ComfyUI Node

XResolution

The resolution node that does the rounding so your model doesn't throw a fit

By Xz3r0-M·Created 8 months ago·Updated about 9 hours ago· 13
XResolution
  • image_or_mask
  • width
  • height
presetCustom
width1280
height720
scale1.0
swapfalse
divisible_modeDisabled
divisible16
width_offset0
height_offset0

Every ComfyUI graph eventually needs a pair of numbers: width and height. The KSampler's latent needs them, Empty Latent Image needs them, and your upscaler wants to know the target. XResolution is a single node that computes that pair for you - from a preset, from an existing image, or from raw values - and then applies the fiddly stuff (scale, swap, rounding to a multiple) in one place.

If you've ever hand-typed 1024×1024 into four different nodes and then had to change all four, you know why this exists. You change the preset once, wire the two INT outputs into whatever needs a resolution, and the whole graph follows.

How it works

The node takes a source resolution and pushes it through a fixed pipeline: source → scale → swap → divisible → offset, then clamps the result to at least 1×1. The source is picked in priority order:

  1. image_or_mask (optional, IMAGE/MASK) - if connected, its resolution wins. This is the genuinely clever bit: it reads the shape of an input tensor, so you can match a ControlNet preprocessor or an upscaler to whatever an earlier node produced.
  2. preset - a big list of common sizes (1920×1080, 1024×1024, 896×1024 for SDXL, 3440×1440 ultrawide, and so on). Any preset other than "Custom" overrides the manual width/height fields.
  3. width / height - only used when the preset is Custom and nothing is plugged into image_or_mask.

After that, scale multiplies both dimensions (2.0 on 1280×720 gives 2560×1440), swap exchanges them, divisible_mode + divisible snap the result to a multiple (Nearest / Up / Down), and width_offset / height_offset add a final ±128 adjustment. The offsets exist for models that need a specific tweak like "1080 + 8 for some reason," and they're applied last, so they can break your divisibility - if you need both, keep that in mind.

The inputs that matter

You'll set most of these once and forget them. The three worth knowing:

  • preset - pick a standard size and stop typing numbers.
  • divisible - set 8/16/32/64 with mode "Up" to keep latent dimensions clean for the VAE. The default is 16 and disabled; enable it when a model complains about non-divisible sizes.
  • image_or_mask - connect an image to derive resolution from it.

Outputs are just width (INT) and height (INT). Wire them into Empty Latent Image's width/height, an image resize node, or anything else that takes a resolution, and your workflow stays in sync.

Installing

It ships in the ComfyUI-Xz3r0-Nodes pack. Easiest via ComfyUI Manager - search "ComfyUI-Xz3r0-Nodes" and hit install. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Xz3r0-M/ComfyUI-Xz3r0-Nodes.git
cd ComfyUI-Xz3r0-Nodes
pip install -r requirements.txt

Then restart ComfyUI. No models to download, no heavy Python deps - the requirements file only pulls in ffmpeg-python, which this particular node doesn't even need (FFmpeg itself only matters for the pack's video/audio save nodes). One quirk of the pack: the author sanitizes filename and path inputs against path traversal, and asks you to stick to plain text and the datetime tokens rather than special symbols. That doesn't really touch XResolution, but it's good to know if you wander into the rest of the pack.

Gotchas

  • Presets override your manual width/height - set preset to "Custom" if you want to type numbers.
  • Offsets apply after divisibility rounding, so a nonzero offset can leave you with a non-divisible result.
  • The node validates that width/height ≥ 1 and scale > 0; nonsense values raise a clean error instead of silently producing garbage. It's the polite kind of failure, and you'll appreciate it when a workflow loads from someone else and hands it a 0.
Category♾️ Xz3r0/Workflow-Processing

Inputs (10)

NameTypeDefaultDescription
presetCOMBOCustomResolution preset (used only when image input is not connected; if preset is not Custom, it overrides custom width/height)
widthINT12801–16384Custom resolution width (used only when preset is Custom and image input is not connected)
heightINT7201–16384Custom resolution height (used only when preset is Custom and image input is not connected)
scaleFLOAT1.00.01–100Scale multiplier
swapBOOLEANfalseSwap width and height
divisible_modeCOMBODisabledHow to adjust resolution to be divisible: Disabled=no adjustment, Nearest=round to nearest multiple, Up=round up, Down=round down
divisibleINT161–128Make resolution divisible by this number (set to 1 to disable, common values: 8, 16, 32, 64)
width_offsetINT0-128–128Add offset to output width (positive=increase, negative=decrease)
height_offsetINT0-128–128Add offset to output height (positive=increase, negative=decrease)
image_or_maskoptIMAGE,MASKImage or mask input for base resolution (takes priority over preset and custom width/height)

Outputs (2)

NameTypeDescription
widthINTOutput resolution width (after preset, scaling, swap, divisible adjustment, and offset)
heightINTOutput resolution height (after preset, scaling, swap, divisible adjustment, and offset)