ComfyUI Node
Ratio and Resolution
Work out a width and height pair from a ratio and a mode: long side, short side, width, height, total pixels (megapixels x 1024²) or a long-side range that follows the image you connect. Both sides are then rounded to the 'multiple' you set. Outputs the ratio string plus the width and height; the canvas previews both in cyan next to their slots and shows the real numbers after a run. Same maths as Goohaitools' ratio-and-resolution node.
Ratio and Resolution
- image
- ratio
- width
- height
◄ratiooriginal►
◄modelong-side►
◄fixed_edge1024►
◄megapixels2.0►
◄long_edge_min512►
◄long_edge_max2048►
◄custom_width1024►
◄custom_height1024►
◄multiple16►
CategoryQG-tools/Image
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| ratio | COMBO | original | Target aspect ratio. 'original' follows the image you connect, 'custom' uses the two custom widgets below. |
| mode | COMBO | long-side | How the size is pinned down. long-side / short-side / width / height all use 'fixed edge'; total-pixels uses 'megapixels'; long-side-range follows the incoming image's long edge clamped between min and max (needs an image). |
| fixed_edge | INT | 10248–10240 | Target edge length for the long-side / short-side / width / height modes; unused by the others. |
| megapixels | FLOAT | 2.00.2–50 | Target area for the total-pixels mode, in megapixels of 1024x1024 (same as ComfyUI's official Resolution Selector); unused by the others. |
| long_edge_min | INT | 5128–10240 | Shortest long edge allowed by the long-side-range mode. Swapped with the maximum automatically when it is larger. |
| long_edge_max | INT | 20488–10240 | Longest long edge allowed by the long-side-range mode. |
| custom_width | INT | 10248–10240 | Width used directly by the 'custom' ratio (still rounded to the multiple). |
| custom_height | INT | 10248–10240 | Height used directly by the 'custom' ratio (still rounded to the multiple). |
| multiple | INT | 160–1024 | Round each side to the nearest multiple of this. A result smaller than one multiple still gets a full multiple; 0 rounds to whole pixels. |
| imageopt | IMAGE | Optional. 'original' reads its size as the base ratio (1:1 when unwired); long-side-range reads its long edge and clamps it (1536 when unwired). |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| ratio | STRING | The aspect ratio as text: the reduced one for original / custom, the dropdown label otherwise. |
| width | INT | Computed width, already rounded to the multiple. |
| height | INT | Computed height, already rounded to the multiple. |