ComfyUI Node
Upscaled Crop/Pad (Best-Res)
If the original resolution can't be scaled to the higher one uniformly (i.e., without stretching), this node detects the appropriate values for cropping/out-painting.
Upscaled Crop/Pad (Best-Res)
- upscale
- do_crop
- crop_width
- crop_height
- crop_x
- crop_y
- do_padding
- pad_left
- pad_top
- pad_right
- pad_bottom
◄upscale1.50►
◄init_width1024►
◄init_height1024►
◄HD_width1536►
◄HD_height1536►
◄strategypad only►
◄align_x0.500►
◄align_y0.000►
CategoryBest Resolution
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| upscale | FLOAT | 1.50 | Only used when <UpscaledCropPadStrategy.EXACT_UPSCALE: 'exact-upscale'> strategy selected. |
| init_width | INT | 10241–9223372036854776000 | Width for original/initial image |
| init_height | INT | 10241–9223372036854776000 | Height for original/initial image |
| HD_width | INT | 15361–9223372036854776000 | Width for the (main/upscaled) HD-image |
| HD_height | INT | 15361–9223372036854776000 | Height for the (main/upscaled) HD-image |
| strategy | COMBO | pad only | If 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. |
| align_x | FLOAT | 0.5000–1 | Where's the image pivot for horizontal alignment (which side stays in place during crop/out-paint): 0 - Left 0.5 - Center 1 - Right |
| align_y | FLOAT | 0.0000–1 | Where's the image pivot for vertical alignment (which side stays in place during crop/out-paint): 0 - Bottom 0.5 - Center 1 - Top |
Outputs (11)
| Name | Type | Description |
|---|---|---|
| upscale | FLOAT | The actual uniform upscale value to do. |
| do_crop | BOOLEAN | Whether post-upscale crop needs to be done to get the specified resolution. |
| crop_width | INT | Width for the post-upscale crop. |
| crop_height | INT | Height for the post-upscale crop. |
| crop_x | INT | X-offset for the post-upscale crop. |
| crop_y | INT | Y-offset for the post-upscale crop. |
| do_padding | BOOLEAN | Whether post-upscale padding and out-paint need to be done to get the specified resolution. |
| pad_left | INT | Left padding for the post-upscale out-paint. |
| pad_top | INT | Top padding for the post-upscale out-paint. |
| pad_right | INT | Right padding for the post-upscale out-paint. |
| pad_bottom | INT | Bottom padding for the post-upscale out-paint. |