Nodes/HWP Nodes/HWP Get Side (Latent)
ComfyUI Node

HWP Get Side (Latent)

The pixel size of a latent, no VAE decode required

By hwprinz·Created 23 days ago·Updated 2 days ago· 1
HWP Get Side (Latent)
  • latent
  • side
sidetrue

The number ComfyUI won't hand you

A latent tensor isn't a pixel image, and ComfyUI won't tell you its dimensions as a plain integer you can wire anywhere. When a second pass - a latent upscale to an exact size, a crop-to-square, a hires-fix stage that needs to know what the first pass actually produced - depends on the size of a latent, someone usually ends up typing a guess into a box. HWP Get Side (Latent) is that missing readout: feed it any LATENT and it returns the longest or shortest side in pixels, no decode needed.

That "no decode needed" bit is the whole point. Getting the size of an image normally means VAE-decoding it first. This node reads the tensor's shape directly, so you learn the pixel dimensions of a latent mid-pipeline without paying for a decode you'd otherwise throw away.

How it works

The math is one line. A latent's samples tensor has the shape (batch, channels, height, width) in latent space, which for the SD 1.5 / SDXL / Flux VAE family is 1/8 the pixel resolution. So the node multiplies height and width by 8 and returns either the larger (longest) or smaller (shortest) of the two, depending on the toggle. That's also why everything it reports is a multiple of 8 by construction - latents don't exist at odd sizes.

After a run it shows the computed number as a bare value below the node, in the same style as the built-in Get Image Size node. That display needs a reasonably recent ComfyUI; on older versions the code just skips it rather than erroring, so nothing breaks.

Inputs and output

Only three things on the face of it:

  • latent - any LATENT: an Empty Latent Image output, something you VAE-encoded, a KSampler result waiting for its second pass. If it's a latent, this node can measure it.
  • side - toggle between longest (default) and shortest.

And one output: side, an INT. Wire it into any integer input - a size/scale node's target dimension, a math node that computes steps or total megapixels from the smaller side, a text display. The value is live, so if the first pass changes resolution, everything downstream recomputes from the real number instead of the stale constant you typed last week.

The honest take

This is a genuinely thin utility - one max-or-min behind a widget. If you only need to know a size once, you can read the number under the node and move on. It earns its place when that size must be derived: you're building an adaptive workflow where a second stage should track whatever the model produced, and you don't want to decode just to learn the dimensions. The one assumption baked in is the standard 8× latent downscale; if you ever feed it a latent from a specialist autoencoder that isn't 8×, the pixel figure will be wrong.

Installation

Part of the small hwprinz/ComfyUI-HWP-Nodes pack - four nodes total, MIT, no Python dependencies, no model downloads. ComfyUI Manager → search "ComfyUI-HWP-Nodes", or:

cd ComfyUI/custom_nodes
git clone https://github.com/hwprinz/ComfyUI-HWP-Nodes

Restart ComfyUI and the node appears as HWP Get Side (Latent) under the HWP category. The same pack also ships HWP Get Side (X/Y), which does the identical longest/shortest pick from plain width and height integers - if your sizes come from widgets rather than a latent, that's the one you want.

CategoryHWP

Inputs (2)

NameTypeDefaultDescription
latentLATENT
sideBOOLEANtrue

Outputs (1)

NameTypeDescription
sideINT