Nodes/Best Resolution/Crop-Pad Strategy (Best-Res)
ComfyUI Node

Crop-Pad Strategy (Best-Res)

A strategy dropdown, broken out as a wire you can switch

By Lex-DRL·Created about a year ago·Updated 5 months ago· 15
Crop-Pad Strategy (Best-Res)
    • strategy
    strategypad only

    ComfyUI lets you wire nearly anything, but a dropdown widget on a node is still stuck on that node. Crop-Pad Strategy (Best-Res) is a one-widget node whose whole job is to turn a dropdown into an output wire: pick a strategy here, and you can feed that choice into Upscaled Crop/Pad (Best-Res) from elsewhere in the graph - swapped by a switch node, changed per batch, or kept tidy on a control panel instead of buried in the middle of a workflow.

    In other words: it's a primitive. It takes the strategy enum in and passes it straight back out. The value is what matters, not the node.

    The four strategies

    When an upscaled image doesn't fit the target HD frame exactly, you have to do something to the extra pixels - and the choice changes the result:

    • pad only (default) - upscale to fit the frame on one side, then add missing pixels on the other for outpainting. Nothing is lost, but the model has to invent the padded region.
    • crop only - upscale to fill the whole frame, then crop the overflow. No outpainting needed, but you permanently lose whatever got cropped off. Good when the composition survives a crop.
    • nearest - automatically pick whichever of the two above discards the fewest pixels by area. The lazy-but-sensible default if you can't decide.
    • exact-upscale - follow your requested upscale value precisely, even if that means the frame is reached with both a crop and a pad. The only strategy that actually uses the upscale input of the crop/pad node.

    If both crop and pad happen, the outputs assume the order upscale → crop → pad.

    Why bother with a passthrough node

    Because Upscaled Crop/Pad already has its own strategy dropdown with the same options, this node can look redundant - and honestly, if you only ever use one strategy, it is. The point is the wire. Pull the strategy out into a node you can bypass, toggle, or drive from a primitive or a batch loop, and you've got a workflow where "crop vs. pad" is a parameter you can experiment with instead of a decision baked in at build time. It's also a nicer place to read the tooltip explaining each option than a crowded node's dropdown.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/Lex-DRL/ComfyUI-BestResolution
    

    or search "Best Resolution" in ComfyUI Manager, install, restart. Dependency is just frozendict; nothing to download, nothing heavy. Wire its strategy output into the strategy input of Upscaled Crop/Pad - or skip it entirely and use the widget. The pack won't judge.

    One honest note: this node (and its sibling Priority (Best-Res)) exists because the author wanted clean, switchable control of the upscale workflow's decisions. If you're not building control-panel-style graphs, you don't need it. It's a tool for people who like their workflows to read like a UI.

    CategoryBest Resolution

    Inputs (1)

    NameTypeDefaultDescription
    strategyCOMBOpad onlyIf the upscaled resolution can't be achieved by uniform scaling of the initial-res, how to tweak the image to get there: • pad only - upscale the image to fit it into the desired frame on one side, then add missing pixels on the other one for outpaint. • crop only - upscale the image to fill the entire frame, then crop extra pixels on one side. • nearest - automatically choose one of the above, to crop/pad the least number of pixels (by area). • exact-upscale - follow the provided upscale-value precisely. This is the only option that uses it. Also, it's the only one that might require both outpainting and crop. In case when both are required, the output values assume this order: upscale -> crop -> pad.

    Outputs (1)

    NameTypeDescription
    strategypad only,crop only,nearest,exact-upscale