Nodes/ComfyUI-MaxedOut/Get Latent Size MXD
ComfyUI Node

Get Latent Size MXD

What resolution is this latent, anyway?

By Maxed-Out-99·Created about a year ago·Updated 21 days ago· 9
Get Latent Size MXD
  • latent
  • width
  • height

Latents don't advertise their resolution. A LATENT is a tensor - [batch, channels, h, w] - and to know what image size it corresponds to you have to know the compression factor of the VAE that made it (8x, 16x, or the odd 32x). Annoyingly, the answer depends on which model family you're using, so "what size is this latent" isn't a one-size-fits-all division. Get Latent Size MXD answers it for you: feed a latent in, get width and height out, in pixels.

What it is

A tiny introspection node - the kind that earns its place when you're building adaptive workflows that need to know their own dimensions. Feed it any LATENT, and it returns the image-space width and height as two INT outputs you can wire into anything that needs to know the size (crop nodes, image prep, math, conditionals).

How it works

The clever bit is the compression detection. The node looks at the latent's channel count to guess the VAE's spatial compression:

  • 16 or more channels → assumes 16x compression (the Flux 2 / heavy-VAE world: 128 channels → 16x).
  • Fewer than 64 channels → assumes 8x (the classic SD3/WAN world: 4–16 channels → 8x).

Then it multiplies the latent's h and w by that factor and returns the pixel dimensions. It also checks for explicit width/height keys stored in the latent dict first, if a node bothered to record them.

The honest caveat: it's a heuristic, not a guaranteed measurement. If a latent was created by a 32x-compression VAE (some video architectures), the 16x assumption would be wrong. In practice, for the SDXL/Flux/WAN latents this pack generates, the heuristic is right.

Inputs and outputs

  • latent - any LATENT.
  • Outputs: width and height (INT, image-space pixels), per the tooltips: "Latent-derived image width/height in pixels."

Where it fits

Classic uses: scaling an image to match a latent's size before feeding it to a VAE decode-comparison; driving a "match this resolution" node so your img2img input lines up with a generated latent; or logging/conditioning on aspect ratio. If you've ever eyeballed a latent size from a shape error message, this replaces that guess with a number.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/Maxed-Out-99/ComfyUI-MaxedOut.git

Restart, or ComfyUI Manager → search "Maxed Out" → install. No dependencies, no models - pure tensor inspection.

Troubleshooting

  • "invalid latent or missing 'samples' tensor" - whatever you connected isn't a proper LATENT dict. Check the socket type.
  • Width/height look doubled (or halved) - the compression heuristic guessed wrong for your model family. If you're working with an exotic 32x-compression VAE, don't trust the number; for the mainstream families it's correct.
  • 0x0 output - you fed in an empty latent with no spatial dims. That's not a real latent.

It's a small utility, but in adaptive workflows it's the difference between hardcoding sizes and letting the graph figure itself out. Tuck it into your template; you'll find a use by week two.

CategoryMXD/Latent

Inputs (1)

NameTypeDefaultDescription
latentLATENT

Outputs (2)

NameTypeDescription
widthINTLatent-derived image width in pixels.
heightINTLatent-derived image height in pixels.