Light-Tool: Get Image Size
Width, height, and file size — as numbers your graph can branch on
- image
- width
- height
- size
Light-Tool: GetImageSize reads an image and hands back its width, height, and - optionally - its file size in bytes, as three typed INT outputs. It's the "what am I actually dealing with here?" node, and it's the gateway to workflows that adapt to whatever image shows up instead of assuming a fixed size.
ComfyUI workflows that load arbitrary images - from a URL, from a folder, from a drag-and-drop - can't know their dimensions in advance. GetImageSize turns that unknown into three numbers you can compare, feed into a resize decision, or pass to a math node. It's the difference between "this workflow only works at 1024×1024" and "this workflow works on whatever you feed it."
How it works
It decodes the tensor to a PIL image and returns width and height directly. The size output is the interesting one: it's the file size in bytes, but only if you flip the output_size toggle on. When on, the node writes the image to a temporary PNG, measures the bytes, and returns that. When off (the default), size comes back as 0.
That toggle is the gotcha to remember. People wire size somewhere expecting a real number, forget the toggle, and get 0 with no explanation. If you want file size, you must enable it - and the cost is a disk write per image, which for large batches means actual I/O. For most workflow logic, width and height are what you want anyway; file size is usually for estimating output weight or deciding whether to compress.
Outputs: width (INT), height (INT), size (INT, bytes, 0 unless output_size is on).
Where it fits
- Adaptive resizing. Read the width, compare it to a target, and only resize when it exceeds the max - a cleaner gate than blind resizing.
- Aspect logic. Feed width and height into
Calculateto derive an aspect ratio or a half-size, then wire that into a resize node. - Format decisions. Use file size to decide between PNG and JPEG at save time.
Pair it with the pack's resize nodes and you can build genuinely self-adapting pipelines: any image in, sensibly sized output out, no hard-coded assumptions.
Gotchas
The output_size-off-means-zero trap is the main one. Batch note: the node reads the image as a whole - if you feed it a batch, it reports the first frame's dimensions, which are assumed uniform. It's not a per-frame measurement. And remember size is measured as a PNG temp file, not the original source file's bytes, so it's an approximation of what a saved PNG would weigh, not the input's on-disk size.
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 → ImageInfo. No models; the file-size path uses Python's tempfile and PIL, both already present.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| output_size | BOOLEAN | false | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| size | INT | — |