Nodes/JPS Custom Nodes for ComfyUI/SDXL Recommended Resolution Calc (JPS)
ComfyUI Node

SDXL Recommended Resolution Calc (JPS)

Snap any image size onto SDXL's trained ratios

By JPS-GER·Created 3 years ago·Updated 2 years ago· 101
SDXL Recommended Resolution Calc (JPS)
    • SDXL_width
    • SDXL_height
    target_width1024
    target_height1024

    SDXL was trained on a fixed shortlist of aspect ratios - 1024x1024, a handful of landscape ratios like 1344x768, their portrait mirrors, and nothing in between. That's fine when you're starting from an Empty Latent Image and can just pick one. It's a real problem the moment you're doing img2img or feeding a ControlNet a photo that happens to be, say, 1920x1080 or some arbitrary phone-camera resolution - because generating at an off-ratio size is exactly what produces the stretched, warped-anatomy look SDXL is known for when pushed outside its comfort zone. This node exists to solve that specific mismatch.

    Give it your image's actual target_width and target_height (both plain integers, defaulting to 1024 and adjustable up to 8192), and it works out which of SDXL's real trained resolutions is the closest fit, returning it as SDXL_width and SDXL_height. It doesn't touch the image itself - this is pure arithmetic, not a resize operation. Think of it as a rounding function where the only valid outputs are the nine buckets SDXL actually knows how to generate at.

    The workflow this is built for. You've got a source photo you want to run through img2img, or a pose/depth map you're about to feed into ControlNet, and it's some off-ratio size that doesn't match anything SDXL trained on. Read the photo's real dimensions with Get Image Size (JPS), pass those straight into this node, and use the result to drive your resize step (or your Empty Latent Image, if you're generating a fresh canvas that should match). The README's own framing calls this out directly: it's "useful for IMG2IMG and ControlNet input images, to bring them in line with SDXL workflows." Pair it with SDXL Resolutions (JPS) and you've got both directions covered - pick a ratio up front, or snap an existing image onto the nearest one.

    Installing it. ComfyUI Manager, search "JPS Custom Nodes for ComfyUI," or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/JPS-GER/ComfyUI_JPS-Nodes.git
    

    Restart and find it under JPS Nodes/Math. If you've got a previous install of the pack, delete it first per the author's own instructions - overlapping copies cause class-name collisions. No models, no extra dependencies; it's a small math function.

    Troubleshooting. There's not much surface area for bugs, but a couple of things trip people up in practice. First, this node finds the nearest trained resolution - it doesn't preserve your original aspect ratio exactly, so a 1600x1000 photo (a 1.6:1 ratio that isn't one of SDXL's nine buckets) will get rounded to whichever bucket is closest, which might crop or stretch slightly once you actually resize to match. That's expected behavior, not a bug: SDXL genuinely doesn't have a bucket for every ratio, and the alternative - generating off-grid - is worse. Second, remember this node only outputs numbers; you still need a resize/crop step downstream (like JPS's own Crop Image nodes, or a standard Image Resize) to actually get your source image to those dimensions before it hits the sampler.

    CategoryJPS Nodes/Math

    Inputs (2)

    NameTypeDefaultDescription
    target_widthINT10240–8192
    target_heightINT10240–8192

    Outputs (2)

    NameTypeDescription
    SDXL_widthINT
    SDXL_heightINT