Nodes/ComfyUI GOAT Nodes/🐐 Get Side Length Of Image
ComfyUI Node

🐐 Get Side Length Of Image

The longest or shortest edge, as one number

By AconexOfficialΒ·Created 2 years agoΒ·Updated 12 months agoΒ· 11
🐐 Get Side Length Of Image
  • image
  • INT
β—„side_lengthtrueβ–Ί

ComfyUI's core "Get Image Size" node hands you width and height separately, which is exactly right most of the time - but sometimes what you actually need is just "the long edge" or "the short edge" as a single number, without adding a Max/Min math node afterward to pick between them. Get Side Length Of Image skips that extra step: point it at an image and it hands back one integer, either the longest side or the shortest, depending on a single toggle.

This kind of value matters more than it sounds like - a lot of upscaling and resize logic (including GOAT's own Advanced Upscale Image node) works off a target long edge or short edge rather than exact width/height, because that's usually what you actually care about when constraining an image to "fit within 2048px" regardless of whether it's portrait or landscape.

How it works

Per the node's description, it "returns the length of the image's longest (max) or shortest (min) side." The single input controlling that is named side_length, which reads more like a mode toggle than a literal length despite the name - set to true (the default) to get the max side, false for the min side, based on the order the node's own description lists them in.

Inputs and outputs that matter

  • image - the source image.
  • side_length (boolean, default true) - the mode switch. Default (checked) reads as "give me the long side"; flip it off for the short side.

One output: INT - the pixel length of whichever side you asked for.

How to install it

ComfyUI Manager: search "GOAT Nodes", install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/AconexOfficial/ComfyUI_GOAT_Nodes.git

then restart ComfyUI. No models, no dependencies - this reads image dimensions and does one comparison.

Common issues & troubleshooting

The side_length input name is genuinely confusing - it's a boolean toggle, not a number, despite what the name suggests. This isn't a documented gotcha, just a naming choice worth flagging so you don't go looking for a numeric widget that isn't there. If the output isn't the side you expected, that toggle is the first thing to check.

Not sure whether true gives you max or min? Test it once on an obviously non-square image (say, 1920x1080) and check the output against the known values - 30 seconds of verification beats guessing, especially since this node feeds directly into resize/upscale math where getting it backwards silently produces a wrongly-scaled result rather than an error.

Square images. If width equals height, the toggle obviously makes no difference - both "sides" are the same length either way.

Category🐐 GOAT Nodes/Image

Inputs (2)

NameTypeDefaultDescription
imageIMAGEβ€”
side_lengthBOOLEANtrueβ€”

Outputs (1)

NameTypeDescription
INTINTβ€”