Light-Tool: Get Side Length
The long edge or the short edge, as a single number
- image
- length
Light-Tool: GetSideLength looks at an image and returns the length of its longest side - or its shortest side - as a single number. It's a distilled version of the info-gathering pattern: instead of getting width and height and doing the comparison yourself, this node hands you the one value you actually wanted.
It answers the question "how big is this image?" in the most useful single-number form. "Is the long edge under 1024?" "Does the short edge clear 512?" Those are the checks you find yourself making constantly when an image's dimensions are unknown until runtime, and this node turns them into a comparison you can wire into a decision.
How it works
Decode the image, read width and height, then apply your choice of mode:
- longest (default) - returns
max(width, height) - shortest - returns
min(width, height)
That's the whole implementation. It's a metadata read - instant, no resizing, no I/O. The single output, length, is a wildcard type that in practice carries the integer side length.
Inputs: image, plus the mode enum. Output: length.
Where you'll actually use it
- Resolution gating. "If the long edge is under 1024, upscale first" - compare the output to a threshold and branch. This is the classic pre-upscale sanity check.
- Adaptive workflows. Feed it into the pack's
Calculateto derive a scaled size, then resize relative to the long edge. - Short-edge minimums. For printing or platform minimums, "make sure the short side is at least X" is the check that matters, and
shortestmode gives it to you directly.
Compared to GetImageSize, which gives you both dimensions plus file size, this node is the narrower, more opinionated sibling: you already know which side you care about, and you don't want to do the max/min yourself. For workflows that only ever need one, it keeps the graph one node smaller and the intent one line clearer.
The honest take
It's a thin node, and it's honest about being one. Its entire job is saving you from wiring width and height into a comparison. That said, thin nodes like this earn their place in utility packs precisely because they're so obviously correct - there's nothing to misconfigure beyond the mode toggle, no failure modes worth worrying about, no surprise behavior. If the wildcard output type ever trips up a strict-typed downstream node, a quick pass through ConvertNumType fixes it.
Install
Standard: ComfyUI Manager → search ComfyUI-Light-Tool, or clone into custom_nodes, pip install -r requirements.txt, restart. It's under ComfyUI-Light-Tool → image → other. Pure Python, no models.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mode | COMBO | longest | 2 options: longest, shortest |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| length | * | — |