ComfyUI Node

LatentSizeToPixelSize

Got a Latent and Need Its Pixel Size? This Node Does the Math for You

By Ling-APE·Created 2 years ago·Updated about a year ago· 8
LatentSizeToPixelSize
  • samples
  • pixel_width
  • pixel_height
latent_block_size8

Somewhere in your Flux workflow you have a latent whose size you no longer know. Maybe a latent-resize node moved it, maybe you loaded a saved latent, maybe you just joined a workflow mid-graph and it was built for you. You need its pixel dimensions to feed into the next node, and the latent itself only tells you its compressed shape - 76×76 or whatever, not the 608×608 the image will actually be. LatentSizeToPixelSize exists to bridge that gap.

It's the inverse sibling of the PixelResolutionCalculator in the same pack: that one turns a megapixel target into dimensions, this one reads a latent and reports what its pixel size already is. Both ship in Ling-APE's ComfyUI-PixelResolutionCalculator, built for the author's All-in-One Flux Dev workflow, and it's about as simple as a node gets.

How it works

Latents aren't stored in pixels. The VAE compresses images by a fixed factor per side - 8× for SD, SDXL, and Flux - so a 608×608 image lives in the latent as an 76×76 tensor. The node reads the last two dimensions of your latent tensor and multiplies each by latent_block_size to recover the pixel dimensions. That's the whole mechanism; the source is ~20 lines.

The inputs that matter

Only two, and both required:

  • samples (LATENT) - plug in the latent output of any sampler, VAE encode, or latent-resize node.
  • latent_block_size (int, default 8) - the VAE's compression factor. Leave it at 8 for SD/SDXL/Flux. If you're on a model whose VAE compresses differently, this is the knob to adjust - get it wrong and every output is off by that factor.

The outputs are pixel_width and pixel_height (both INT), which you can wire into anything that wants pixel sizes: an upscale target, a conditioning-area width/height, a tiling node, or just as a sanity check next to the node you resized with.

Installing it

Same story as its sibling: this pack has no dependencies and downloads nothing. ComfyUI Manager → search ComfyUI-PixelResolutionCalculator → Install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Ling-APE/ComfyUI-PixelResolutionCalculator

Restart ComfyUI and it shows up in the image category as "Latent Size to Pixel Size".

Common issues

The one real trap is the block size. If you set latent_block_size to something that doesn't match the VAE's actual compression, you get confident-looking but wrong pixel values - the node won't warn you, because from its side the math is fine. Also note it reports the first item in the batch, which is fine in practice since batch members always share a size, but don't expect per-item numbers if you're doing something exotic. Otherwise it's a boring, reliable little utility, and boring is exactly what you want from a node that exists so you don't do mental arithmetic.

Categoryimage

Inputs (2)

NameTypeDefaultDescription
samplesLATENT
latent_block_sizeINT81–100

Outputs (2)

NameTypeDescription
pixel_widthINT
pixel_heightINT