π Image Size
Read width/height (with a max-size cap)
- image
- latent
- width
- height
This node reads the width and height off an image (or a latent) and hands them back as plain integers you can wire into anything that needs dimensions. It's connective tissue - the kind of node that makes a workflow adapt to its input instead of hardcoding 1024Γ1024 everywhere. Load an arbitrary image, pull its size, and feed those numbers into an empty latent, an upscaler, or a crop, and your graph now handles whatever resolution shows up.
The genuinely useful extra is the max-size cap. It doesn't just report dimensions; it can proportionally scale them down to a ceiling while keeping the aspect ratio, which is the exact math you'd otherwise do by hand every time you want to bound a generation to, say, 1024 on the long edge.
How it works
You give it an image or a latent (either works), it measures the dimensions, and outputs them as two INTs. If maxsize is set above 0, it computes the largest width/height that fits inside that ceiling without changing the aspect ratio, and returns those instead. Set maxsize = 0 and it returns the true, unscaled dimensions.
The inputs and outputs that matter
imageorlatent(both optional) - the thing you're measuring. Wire whichever you have; a latent is handy when you want dimensions mid-pipeline without decoding to pixels first.maxsize- the aspect-preserving ceiling.0= report the real size; any positive value = scale the reported dimensions down to fit. This is what makes it more than a ruler.
Outputs are width and height (INT). Feed them into an Empty Latent's width/height, an upscale-to node, a crop, or anywhere a dimension is expected.
How to install it
ComfyUI Manager: search SDVN_Comfy_node, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableDiffusionVN/SDVN_Comfy_node
then pip install -r custom_nodes/SDVN_Comfy_node/requirements.txt from your ComfyUI root, and restart. This one lives under SDVN β Creative (not Image, oddly), so look there if you can't find it.
Common issues & troubleshooting
The numbers are smaller than my actual image. That's maxsize doing its job. If you wanted the true dimensions, set maxsize to 0.
Odd dimensions break my sampler. Diffusion models want multiples of 8 (often 64). If you pipe raw measured dimensions from an arbitrary photo straight into an empty latent, you can land on a non-multiple and get an error. Use maxsize to bound it, and if needed round to a multiple downstream.
I want the size of a masked region, not the whole image. Wrong node - that's Get Mask Size in this same pack, which takes a MASK and returns its width/height.
Both image and latent are wired. They're both optional so the node is flexible, but feed it one source at a time to avoid ambiguity about which it measures.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| imageopt | IMAGE | β | |
| latentopt | LATENT | β | |
| maxsizeopt | INT | 00β10240 | 0 = noset |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| width | INT | β |
| height | INT | β |