Nodes/ComfyUI-Muye-nodes/图像比例/分辨率读取
ComfyUI Node

图像比例/分辨率读取

The tiny node that answers 'what size is this, anyway?'

By muyexiuluo·Created about a year ago·Updated 30 days ago· 89
图像比例/分辨率读取
  • image
  • 比例
反转false

Some nodes do AI. Some nodes do math. ImageInfo is a math node, and it's about as simple as the Divergent Nodes suite gets: feed it an image tensor, get back its dimensions, batch count, channels, and aspect ratio. That's the whole job.

Which sounds boring until you're mid-workflow and need a number. The kind of number you can't just eyeball. ImageInfo is what you reach for when you want an image's width to drive something downstream - a crop math node, an upscaler decision, a conditioning that depends on resolution. It's the "tell me what I'm holding" node, and it's genuinely handy in conditional graphs where the pipeline should react to what it just produced.

How it works

The mechanism is a tensor shape read. ComfyUI's IMAGE tensors are [B, H, W, C] - batch, height, width, channels - and this node unpacks those four values directly. Aspect ratio is width / height (a flat 0.0 if height is somehow zero, which won't happen with real images), and is_landscape is simply width > height. Nothing is resized, nothing is analyzed; the pixel data isn't even looked at. It's instant and it's free.

Inputs and outputs

Just one input:

  • image - the IMAGE tensor to inspect.

Six outputs, all of them literal:

  • width (INT), height (INT) - the pixel dimensions.
  • batch_size (INT) - how many images are in the tensor. Zero if it's a single image.
  • channels (INT) - usually 3 for RGB, 4 with an alpha channel.
  • aspect_ratio (FLOAT) - width over height. Above 1 is wider than tall.
  • is_landscape (BOOLEAN) - true when width beats height.

The pair worth wiring up are aspect_ratio and is_landscape - they're the two things ComfyUI usually doesn't hand you directly, and they're exactly what you want for orientation-aware logic like choosing between a landscape and portrait upscale path.

Installing it

It rides in the Divergent Nodes pack alongside everything else:

cd ComfyUI/custom_nodes
git clone https://github.com/thedivergentai/divergent_nodes.git divergent_nodes
cd divergent_nodes
pip install -r requirements.txt

Or search "Divergent Nodes" in ComfyUI Manager. Same story as the rest of the suite: it's written against the newer v3 node API, so keep ComfyUI current.

The honest take

If you just need to know your canvas size before you start, you don't need this node - you set the size. Where ImageInfo earns its keep is as a signal in an adaptive workflow: an image whose aspect ratio changed mid-pipeline, a batch whose size you need to count, a conditional that forks on orientation. For that it's clean and dependency-free, and it costs you nothing to keep in the graph. Not a headline node. A quiet utility that shows up when the workflow needs to know what it's carrying.

CategoryMuye/图像

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
反转BOOLEANfalse

Outputs (3)

NameTypeDescription
INT
INT
比例STRING