ComfyUI Node

Scaler | Megapixels

Target a pixel budget, not a dimension — 'give me about 1MP'

By wmpmiles·Created 2 years ago·Updated about a year ago· 5
Scaler | Megapixels
    • scaler
    megapixels1.000

    Scaler | Megapixels is the sizing node for when you care about how much image you have, not its shape. One input, megapixels (FLOAT, default 1.0, min 0.001), and it resizes whatever it's wired to so the total pixel count lands at that target - aspect ratio preserved, dimensions figured out for you. "I want about a megapixel" is a real request, and this is the node that answers it.

    Why think in megapixels at all? Because in ComfyUI, pixel count is usually the thing you're actually budgeting. VRAM on the decode, denoise time, and the "is this too big to sample" question all scale with area, not with either side. Telling someone your workflow is "2MP in, 1MP out" is more informative than "1024×2048 → 1024×1024," and this node lets you set the pipeline that way directly.

    How it works

    Given the current size and the target, the node computes target_megapixels / current_megapixels as an area ratio and scales each side by its square root, so a 4K image (about 8.3MP) at megapixels = 2 lands near 1448×1448. The math is the same as Scaler | Area, just expressed as an absolute target instead of a relative multiplier. Output is a scaler wire into Resample Image, Resample Mask, Resample Latent, or the inpaint Pre node.

    The 1.0 default is a handy sweet spot: it's roughly SDXL-native total area, and a common pattern is downscaling oversized sources to ~1MP before a detail pass so the model sees a sharp image at a size it understands. For SD 1.5-era workflows you'd use a smaller number, since 1MP is way over native - this node respects your model's scale because you set the number.

    Pairing it up

    The scaler sets the size; the resampler sets the method, and the two should agree on direction. Shrinking to a pixel budget? Resampler | Area so the downscale doesn't alias. Growing? Resampler | Lanczos or Resampler | Mitchell-Netravali. And if you're resizing latents, remember the target is latent megapixels there - keep it aligned with what your model and VAE expect rather than your final display size.

    Installing

    Ships in comfyui-some-image-processing-stuff:

    cd ComfyUI/custom_nodes
    git clone https://github.com/wmpmiles/comfyui-some-image-processing-stuff
    

    Restart, or use ComfyUI Manager → search "Some Image Processing Stuff". No models, no dependencies beyond PyTorch. Whole pack installs in one clone, so the scaler shows up alongside all six resamplers and the Resample nodes that consume them.

    Categoryresampling/scaler

    Inputs (1)

    NameTypeDefaultDescription
    megapixelsFLOAT1.000

    Outputs (1)

    NameTypeDescription
    scalerSCALER