Nodes/was-node-suite-comfyui/Image Aspect Ratio
ComfyUI Node Runs on cloud

Image Aspect Ratio

Read a picture's shape and branch a workflow on it

By WASasquatch·Created 3 years ago·Updated about 14 hours ago· 1,840
Image Aspect Ratio
  • image
  • width
  • height
  • aspect_number
  • aspect_float
  • is_landscape_bool
  • aspect_ratio_common
  • aspect_type
  • is_landscape_float
  • is_landscape_int

This node doesn't change your image - it measures it. Feed it a picture and it tells you the aspect ratio three ways: as a raw float, as a human-readable common format like 16:9, and as a plain label for whether the thing is portrait, landscape, or square. The WAS README lists exactly that trio. It's a read-only inspector, and it's more useful than it sounds the moment you're building anything that has to handle images of unknown shape.

The reason you'd want it: automation. If you're batch-processing a folder where some images are tall, some wide, some square, you can't hardcode one set of dimensions. Image Aspect Ratio lets the workflow see the shape and react - pick a target resolution, choose a crop strategy, route portraits down one branch and landscapes down another.

How it works

It divides width by height and reports that number, then also translates it into the nearest tidy ratio string and a category. The portrait/landscape/square label is just the sign of that comparison made friendly: taller than wide is portrait, wider than tall is landscape, equal is square. Nothing mysterious - it's doing the arithmetic you'd do in your head, but as data your other nodes can consume.

The inputs and outputs that matter

  • The image in - the picture whose shape you want to know.
  • A float ratio out - the exact width/height number, handy for feeding into math or comparison nodes.
  • A common-format string out - the readable 16:9-style label.
  • An orientation out - portrait, landscape, or square, which is the one you'll usually branch on.

I'm naming these from the README's own description of what it returns, not from a formal schema, so treat them as the shape of the outputs rather than exact port labels. The interesting move is wiring the float or the orientation into a switch or a condition node so the rest of the graph adapts automatically.

How to install it

Comes with the WAS Node Suite:

  • ComfyUI Manager: search was-node-suite-comfyui, install, restart.
  • Manually: cd ComfyUI/custom_nodes && git clone https://github.com/WASasquatch/was-node-suite-comfyui/, then pip install -r requirements.txt against your ComfyUI Python, and restart.

It's a pure measurement node - no model, no heavy dependency. The suite's chunky downloads only load for the nodes that use them.

Common issues

The main thing to keep in mind is that a float ratio and a "common format" don't always agree cleanly. A photo at 1.775 isn't exactly 16:9 (which is 1.777…), so the common-format output snaps to the nearest recognizable ratio while the float stays precise. If you're making decisions, branch on the float or the orientation label, not on string-matching the common format - otherwise an oddball resolution that rounds to an unfamiliar ratio can slip through your logic.

There's no output image here, so if you wired this expecting a processed picture, that's the confusion - it's an analyzer, full stop. Send the original image around it to whatever does the actual work.

And the pack-wide caveat holds: WAS Node Suite has been retired since December 2023, still widely used but unmaintained, so a ComfyUI update can make every WAS node vanish with an "Import Failed." That's suite-wide dependency drift, not this node - re-run requirements.txt against the correct Python environment (or the bundled install.bat) and restart.

CategoryWAS Suite/Number/Operations

Inputs (3)

NameTypeDefaultDescription
imageoptIMAGEThe image to measure. Only needed when width and height are not both given; with no image and no pair of sizes the node stops with an error. A batch is measured at its first image, since each output carries one value.
widthoptNUMBER,INT,FLOATWidth in pixels, measured instead of the image. It is used only when height is given too, and a value of 0 counts as not given.
heightoptNUMBER,INT,FLOATHeight in pixels, measured instead of the image. It is used only when width is given too, and a value of 0 counts as not given.

Outputs (7)

NameTypeDescription
aspect_numberNUMBERWidth divided by height: roughly 1.78 for 1920x1080, 0.5625 for 1080x1920, and exactly 1.0 for a square.
aspect_floatFLOATThe same width-over-height ratio, on a FLOAT socket.
is_landscape_boolNUMBER1 when the image is wider than it is tall, 0 when it is taller or square. A number rather than a true/false value.
aspect_ratio_commonSTRINGThe ratio reduced to whole numbers, such as 16:9 for 1920x1080 or 1:1 for a square. A fractional width or height is cut to a whole number before reducing.
aspect_typeSTRINGThe orientation as a word: 'landscape', 'portrait' or 'square', ready to drop into a prompt or a file name.
is_landscape_floatFLOATThe same landscape flag as 1.0 or 0.0.
is_landscape_intINTThe same landscape flag as 1 or 0, on an INT socket.