Nodes/ComfyUI-ZML-Image/ZML_限制分辨率格式
ComfyUI Node

ZML_限制分辨率格式

Round your numbers to a multiple — resolution hygiene

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_限制分辨率格式
    • 结果_A
    • 结果_B
    倍数8
    模式
    数值_A
    数值_B

    Diffusion models have opinions about your dimensions. SDXL, Wan, and most of the modern lineup want widths and heights that are multiples of 8 (often 16 or 64), and the moment you type 1152×864 into an EmptyLatent instead of 1152×864→the nearest valid number, you get either an error or a silently rescaled latent that doesn't match what you asked for. ZML_LimitResolution (ZML_限制分辨率格式, "limit resolution format") is a two-input integer node that exists to catch that before it bites: it rounds your numbers up or down to the nearest multiple and hands you clean values.

    It's from ComfyUI-ZML-Image, zml-w's 160+ node pack, and it's one of the pack's earliest ideas - the README calls out the resolution-formatting node from the very first feature list. It lives in the integer subcategory.

    How it works

    The node takes up to two integers (数值_A and 数值_B), rounds each to a multiple of 倍数 (default 8), and outputs them as 结果_A and 结果_B. The 模式 picks the direction:

    • 取大 (round up) - ceil to the next multiple: 1150 → 1152.
    • 取小 (round down) - floor to the previous multiple: 1153 → 1144.

    Default multiple 8 is the sweet spot for most models; set 16 or 64 for the video models (Wan's frame and resolution formats are the README's own suggested use) that want chunkier alignment. Either input is optional - leave one empty and you just get the other, rounded.

    What it's actually for

    Drop it between a resolution source and an EmptyLatent. If you're computing dimensions from an aspect ratio or a percentage node and the math lands on an odd number, this node rounds it into the valid range before the latent exists - no error, no silent rescale, no "why is my image 1144 wide when I asked for 1153."

    The pack's README frames it as a format formatter: normalize the resolution you generate at, and separately clamp Wan-style video resolutions and frame counts into their required multiples. Same node, two jobs, both just "round to a multiple."

    Installing it

    Pack install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/zml-w/ComfyUI-ZML-Image
    

    restart ComfyUI, or ComfyUI Manager → search "ComfyUI-ZML-Image". Pure integer math - no dependencies beyond core, no models, nothing to download. This is as light as a node gets.

    Where people get caught

    The rounding is dumb and proud of it - it doesn't resize anything, it just fixes the numbers. Rounding up 1150 to 1152 changes the aspect ratio by a hair (0.17%), which for most purposes is invisible and exactly why the convention exists. But if you're chaining a strict ratio elsewhere, round after computing the ratio from your target, not before, or the aspect drifts.

    Second, remember it returns two values that correspond to your two inputs. Wire 数值_A → 结果_A and 数值_B → 结果_B in the order you care about; swap them and your width and height quietly swap too.

    When you'd actually reach for it

    Whenever a computed resolution needs to survive contact with a model. It's the boring kind of node that never makes a showcase workflow - and the exact kind that saves you from a "latent doesn't match requested resolution" headache at 2am. Keep one wired before your EmptyLatent and you'll stop thinking about multiples entirely.

    Categoryimage/ZML_图像/整数

    Inputs (4)

    NameTypeDefaultDescription
    倍数INT81–256
    模式COMBO2 options: 取大, 取小
    数值_AoptINT
    数值_BoptINT

    Outputs (2)

    NameTypeDescription
    结果_AINT
    结果_BINT