Nodes/ComfyUI-WJNodes/get image data
ComfyUI Node

get image data

Pull batch, width, height, channels straight out of an image

By 807502278·Created 2 years ago·Updated 11 months ago· 20
get image data
  • images
  • masks
  • images
  • masks
  • N
  • H
  • W
  • C
  • shape

get_image_data answers the boring but genuinely useful question: what am I actually holding? Wire in an image or a mask, and it hands back the batch count, height, width, and channel count as plain INT values you can feed straight into other nodes - a resize node's width/height fields, a math node, a conditional branch - instead of hunting for that information by eye or guessing.

It's part of ComfyUI-WJNodes' GetData category, a small cluster of introspection nodes inside a much larger personal pack (807502278: "a simple node package that I use myself") that mostly does image cropping, video slicing, and color work.

How it works

There's nothing clever happening here - it reads the tensor shape off whatever you connect and reports it back in plain terms. If you connect both an image and a mask at once, the node prioritizes the image data for its size outputs, which matters if you're piping both through the same graph section and only want one set of numbers.

The inputs and outputs that matter

  • images / masks - both optional, and you can connect either or both. If both are connected, image data wins for the size calculations.

Outputs: images and masks passed straight through (so this node is free to leave inline without breaking your data flow), plus N (batch count), H (height), W (width), C (channel count), and shape - the full array of that information bundled as a list, in case you want the whole thing at once rather than wiring four separate INT outputs.

How to install it

Through ComfyUI Manager, search "ComfyUI-WJNodes." Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-WJNodes.git

Restart ComfyUI. Nothing to download - this is a shape-reading utility, not a model-driven node.

Common issues & troubleshooting

Both an image and mask are connected, but the numbers only reflect one of them. That's the documented priority behavior - image wins when both are present. If you actually need the mask's dimensions specifically, disconnect the image input temporarily, or use a second get_image_data node with only the mask wired in.

Node has no error, but also no useful output. Both inputs are optional, so it's possible to leave this node with nothing connected at all and get back default/empty values rather than an error - double-check your wiring if the numbers look suspiciously like zeros.

Channel count (C) doesn't match what you expected. ComfyUI images and masks aren't always shaped the way you'd assume - a mask is typically single-channel while an RGBA image carries four. If a downstream node is rejecting your data, checking C here first is a faster diagnosis than guessing.

Nothing published about this specific node. It's a small, low-drama utility inside a personal pack with no real community footprint - but it's also about as simple as ComfyUI nodes get, so there's little to actually go wrong. If a number looks off, trust it over your assumption about what your upstream node was producing.

CategoryWJNode/GetData

Inputs (2)

NameTypeDefaultDescription
imagesoptIMAGE
masksoptMASK

Outputs (7)

NameTypeDescription
imagesIMAGE
masksMASK
NINT
HINT
WINT
CINT
shapeLIST