ComfyUI Node
Best-Res (area+scale)
The most efficient way of selecting an optimal resolution: image size selected indirectly - by the total desired resolution (area) + aspect ratio... ... PLUS, account for the immediate upscale right away. Desired resolution (aka image area/megapixels/pixel count) is specified with a side of a square image. This isn't accidental: most models disclose what image resolution they're trained on, and usually they're square: - SD 1.5 - 512x512 pixels - SDXL - 1024x1024 pixels By simply providing this single number and setting your aspect ratio/orientation, you get the width and height to produce the closest total resolution to the training set, while also respecting image proportions and step-rounding.
Best-Res (area+scale)
- upscale
- init_width
- init_height
- HD_width
- HD_height
◄square_size1024►
◄step48►
◄landscapetrue►
◄aspect_a16►
◄aspect_b9►
◄priorityoriginal►
◄upscale1.50►
◄HD_step144►
CategoryBest Resolution
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| square_size | INT | 10241–9223372036854776000 | The total resolution of the image would be the same as of a square with this side. The width and height would be such to respect aspect ratio, but also be as close as possible to the total number of pixels as in this square image. - 512x512 square (SD 1.5): ~0.25 megapixels - 1024x1024 square (SDXL): ~1 megapixel |
| step | INT | 481–9223372036854776000 | Both width and height will be divisible by this value - by rounding them to the closest appropriate resolution. The default 48 is (8 * 3 * 2), so it's a safe choice because: - it's compatible with SD1.5/XL downsampling factor (divisible by 8), - it can be upscaled by x1.5 or x1.333 at the first iteration, which is optimal for latent-upscale, - after x1.5 upscale, if you only do x2 later (it's OK for already high resolutions) - it will be divisible by 3 AND 9, which might become handy at that point, where you'll probably use UltimateSDUpscale. Other values worth trying first: 64, 96, 128. |
| landscape | BOOLEAN | true | Specifies image orientation: When ON, width is bigger (image is horizontal). When OFF, height is bigger (image is vertical). |
| aspect_a | FLOAT | 16 | Two aspects together define an aspect ratio (16:9, 4:3, etc). Order doesn't matter: image orientation is defined by the 'landscape' toggle. The specified aspect ratio is APPROXIMATE: step parameter has priority over the exact image proportions. |
| aspect_b | FLOAT | 9 | Two aspects together define an aspect ratio (16:9, 4:3, etc). Order doesn't matter: image orientation is defined by the 'landscape' toggle. The specified aspect ratio is APPROXIMATE: step parameter has priority over the exact image proportions. |
| priority | COMBO | original | Defines what resolution to prioritize, as well as which order to perform rounding in: • desired - first, approximate resolutions are calculated for both initial and upscaled size; then, both are rounded. In both cases, the rounded resolution is closest to the desired one, but aspect ratio might differ the most between sizes. • original - first, initial resolution is calculated and rounded; then, upscaled one is detected from it. Upscaled resolution might differ the most from the desired aspect ratio, but it follows the ratio from initial size as much as possible. • upscaled - vice versa: first, the rounded upscaled resolution is calculated; then, the initial one back-tracked from it. |
| upscale | FLOAT | 1.50 | — |
| HD_step | INT | 1441–9223372036854776000 | Same as the main `step`, but for the upscaled resolution. 144 = 8 * 2 * 3 * 3 |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| upscale | FLOAT | If the HD resolution can be achieved by uniformly scaling the initial one (there is "✅" and not "⚠️" in the upscale-line of the status message), outputs this precise upscale-value (might be different from the one originally set on the node itself). Otherwise, outputs the original upscale-value intact. In this case, you shouldn't use it directly and instead should pass it to the "Upscaled Crop/Pad (Best-Res)" node and use the upscale-output from it. In both cases, it won't hurt to use the "Upscaled Crop/Pad (Best-Res)" node and just rely on it's `do_crop` and `do_padding` toggle-outputs. |
| init_width | INT | Width for original/initial image |
| init_height | INT | Height for original/initial image |
| HD_width | INT | Width for the (main/upscaled) HD-image |
| HD_height | INT | Height for the (main/upscaled) HD-image |