Nodes/CRT-Nodes/Scale Latent To Megapixels (CRT)
ComfyUI Node

Scale Latent To Megapixels (CRT)

Scale to a resolution target, not a pixel size

By PGCRT·Created 2 years ago·Updated a day ago· 132
Scale Latent To Megapixels (CRT)
  • samples
  • LATENT
upscale_method
megapixels1.00

Most scaling nodes ask "how many pixels wide?" Scale Latent To Megapixels (CRT) asks a better question for production: "how many *megapixels total?" It rescales a latent to a target area - 1.0 MP, 2.5 MP, whatever you set - and keeps the aspect ratio intact. One number in, and any input shape lands on the same budget.

That framing is the actual use case: models and workflows have a sweet-spot resolution. Flux-class models want around a megapixel. If you're feeding a folder of images with wildly different aspect ratios through a batch workflow, a megapixel target normalizes them all to the same compute and quality tier without you babysitting each dimension.

How it works

Latents are stored 8× smaller than pixels, so the node computes the current pixel area from the latent's dimensions (width × 8 by height × 8), then scales by the square root of target_pixels / current_pixels. That square root is what preserves aspect ratio - double the megapixels means ~1.41× on each side. The resize itself uses ComfyUI's common_upscale with your chosen method.

Important framing from the upscaling playbook: this is latent-space scaling - the cheapest kind. It happens before sampling, adds no detail, and invents nothing. If the image already has the detail you want and you just need pixels, that's a pixel-upscaler job (ESRGAN, Lanczos) after the VAE decode, not this. If you want the model to invent detail, that's a generative upscaler (SeedVR2-style). This node's job is: get the latent to the right size for the sampler with zero fuss.

Inputs

  • samples - the LATENT (from a VAE encode or another latent node).
  • upscale_method - nearest-exact, bilinear, area, bicubic, bislerp. nearest-exact and area are the safe, fast defaults; bislerp is ComfyUI's fancier latent interpolation, marginally smoother, slower.
  • megapixels (0.01–200) - the target area. 1.0 = one megapixel, the classic Flux-ish default.

Output is a single LATENT, ready for your KSampler.

Where you'll use it

  • Batch workflows over mixed-aspect images, standardized to one megapixel budget.
  • Latent-space hires pre-scale: bump the latent to 1.5× before a second sample pass.
  • Matching a model's sweet spot without hardcoding width/height.

Gotchas

  • It operates on latents, so the output is still in latent space - you still need the VAE decode step to see it.
  • Aspect ratio is preserved, which means the actual pixel dimensions may not be the round numbers you're used to. If a model strictly needs divisible-by-64 dims, check the output shape rather than assuming.
  • Bigger isn't free: scaling up the latent scales up the sampling cost roughly with area, so a 2 MP target on a Flux workflow will measurably slow your runs.

Install is the shared pack story: ComfyUI Manager → search CRT-Nodes → install and restart, or clone the repo into custom_nodes. It's a heavy suite, but it loads gracefully - optional nodes that fail to import get skipped without breaking the UI.

CategoryCRT/Latent

Inputs (3)

NameTypeDefaultDescription
samplesLATENT
upscale_methodCOMBO5 options: nearest-exact, bilinear, area, bicubic, bislerp
megapixelsFLOAT1.000.01–200

Outputs (1)

NameTypeDescription
LATENTLATENT