Nodes/ComfyUI-QG-tools/Ratio and Resolution
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.

By live1617·Created about a month ago·Updated a day ago· 4
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)

NameTypeDefaultDescription
ratioCOMBOoriginalTarget aspect ratio. 'original' follows the image you connect, 'custom' uses the two custom widgets below.
modeCOMBOlong-sideHow 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_edgeINT10248–10240Target edge length for the long-side / short-side / width / height modes; unused by the others.
megapixelsFLOAT2.00.2–50Target area for the total-pixels mode, in megapixels of 1024x1024 (same as ComfyUI's official Resolution Selector); unused by the others.
long_edge_minINT5128–10240Shortest long edge allowed by the long-side-range mode. Swapped with the maximum automatically when it is larger.
long_edge_maxINT20488–10240Longest long edge allowed by the long-side-range mode.
custom_widthINT10248–10240Width used directly by the 'custom' ratio (still rounded to the multiple).
custom_heightINT10248–10240Height used directly by the 'custom' ratio (still rounded to the multiple).
multipleINT160–1024Round each side to the nearest multiple of this. A result smaller than one multiple still gets a full multiple; 0 rounds to whole pixels.
imageoptIMAGEOptional. '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)

NameTypeDescription
ratioSTRINGThe aspect ratio as text: the reduced one for original / custom, the dropdown label otherwise.
widthINTComputed width, already rounded to the multiple.
heightINTComputed height, already rounded to the multiple.