Nodes/ComfyUI Archon Nodes/Scale to Best Fit Resolution
ComfyUI Node

Scale to Best Fit Resolution

Scale your canvas 1.5x without landing on a resolution your model hates

By esbe1175·Created 6 months ago·Updated 6 months ago· 1
Scale to Best Fit Resolution
    • width
    • height
    • applied_scale
    • megapixels
    width832
    height1216
    scale1.50
    divisor64

    Here's a familiar failure: you take a clean 832×1216 canvas, hit "scale 1.5x" with your favorite resize node, and get 1248×1824 - a perfectly reasonable-looking pair that is not a multiple of 64, which is exactly the kind of off-multiple resolution that makes a model render mushier than it should. ScaleToBestFitResolution is the fix: it scales your current width and height by a factor, then snaps the result to the nearest multiple of divisor while keeping the aspect ratio as close as it can.

    It's the sibling of MegapixelsToBestFitResolution in the same pack. That node starts from an absolute pixel budget; this one starts from your existing canvas and a multiplier. Same search algorithm underneath, different question being answered: not "how big should this be?" but "what's my current canvas, scaled, cleaned up?"

    How it works

    Given your width and height, it computes the original pixel count, multiplies by scale to get a target, then runs the shared best-fit routine: ideal dimensions at the target aspect (sqrt(pixels * aspect)), round to the nearest multiple of divisor, then a bounded search (up to 80 steps each way) scoring every candidate by weighted pixel error plus aspect error. The winner is returned as clean integers. Pixel error is weighted ten times heavier than aspect drift, so you get a resolution very close to your target area without distorting the shape.

    The inputs and outputs

    Inputs are minimal: width and height (your current canvas), scale (default 1.5 - the classic hires-pass multiplier), and divisor (default 64, the tile multiple your model wants).

    Outputs: width and height as INTs for the next EmptyLatentImage or latent resize, plus applied_scale - the actual ratio after snapping, which will be something like 1.49 or 1.51 rather than your nice round 1.5 - and megapixels, so you know the pixel load you're committing to. That last one matters if you're budgeting VRAM: 1.5× on an 832×1216 canvas is about 2.3 MP, and the node will tell you the real number after snapping.

    Installing it

    One of five nodes in comfyui-archon-nodes; installing the pack installs it. ComfyUI Manager → "Archon Nodes", or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/esbe1175/comfyui-archon-nodes
    pip install -r ComfyUI/custom_nodes/comfyui-archon-nodes/requirements.txt
    

    Restart and find it under Archon/Resolution. It's pure Python - the requests and cloudscraper lines in requirements.txt belong to the pack's Booru node, not this one. No models to download.

    Where it fits

    This is a hires-pass helper. The classic anime workflow generates at native resolution, upscales, and re-runs at low denoise to add detail; this node sits at the seam, converting "I want 1.5× more pixels" into a concrete, model-friendly pair. It also pairs naturally with the pack's prompt nodes - an "archon" style pipeline where the resolution and prompt assembly are both automated.

    Gotchas

    • applied_scale will not equal your input scale. That's not a bug, it's the contract: you asked for "about 1.5×," you get the closest clean resolution. If you need the exact ratio for downstream math, use applied_scale - the node hands it to you precisely because you can't assume the input.
    • Same caveat as its sibling: for the older SDXL anime checkpoints with discrete trained ratios, a generic multiplier is a worse guide than the known preset list (1024×1024, 1216×832, etc.). For the megapixel-band models of the 2025–2026 era, scaling into range is exactly right. Know which camp your checkpoint is in.

    It's a small, mechanical node, and you'll probably forget it's there once it's wired in. That's the review it deserves.

    CategoryArchon/Resolution

    Inputs (4)

    NameTypeDefaultDescription
    widthINT8321–65535
    heightINT12161–65535
    scaleFLOAT1.500.01–100
    divisorINT641–4096

    Outputs (4)

    NameTypeDescription
    widthINT
    heightINT
    applied_scaleFLOAT
    megapixelsFLOAT