Image: Downscale to Total Pixels (lab)
Shrink images to a pixel budget without touching the aspect ratio
- image
- image
- width
- height
- actual_size
Image: Downscale to Total Pixels (lab) resizes an image so its total pixel count lands on a target in megapixels - 1 MP, 2.5 MP, whatever you ask for - instead of forcing a specific width × height. If the image is already at or below the target, it's passed through untouched. If it's bigger, it shrinks, cropping a little to keep the aspect ratio rather than stretching.
It's the downscale-only sibling of ComfyUI's core ImageScaleToTotalPixels, and there are three situations where you'll actually reach for it.
One: pre-processing a soft source before an upscaler. The KB digs into this - Comfy Org's own guidance for SeedVR2 is to drop the input to 0.35 megapixels first when the source is out-of-focus rather than genuinely small, on the theory that an upscale from blurry-full-res just keeps the blur. Any upscaler that wants a normalized input benefits from this. Two: normalizing wildly different resolutions before a batch, so every image in a queue hits the model at the same pixel budget. Three: taming a huge image before it blows past your VRAM.
How it works
The target is megapixels × 1024 × 1024 actual pixels. The node computes a scale factor from the square root of target / current, which is what keeps the aspect ratio intact, then resizes with your chosen method and center-crops to the final size. That crop is the deliberate part: the description says it plainly - "image may be cropped, to prevent stretching." Better to lose a strip of edge than to squish everything.
The multiple_of input (default 0, off) rounds both dimensions up to a multiple of that number, which matters when you're feeding a model whose latent space wants multiples of 8, 16, or 64.
The inputs that matter
- image - the tensor you want shrunk.
- megapixels - target size, a float from 0 to 16 in 0.1 steps, default 1. Set it to your model's comfortable budget; 1 MP is a fine default.
- downscale_method -
lanczos(default),bicubic,bilinear,area,nearest-exact. For normal photos leave lanczos. For pixel art,nearest-exactkeeps the crisp edges;areais the classic "honest" downscale and rarely a bad call. - multiple_of - 0 to disable, otherwise dimension rounding.
Outputs: the resized image, plus width and height as ints and actual_size - the real MP after cropping, which is usually a hair below what you asked for. The actual_size output is genuinely useful for sanity-checking a pipeline.
Install
ComfyLab Pack is one install for its whole node family (nodes display with a "(lab)" suffix). ComfyUI Manager: search ComfyLab Pack, install, restart.
cd ComfyUI/custom_nodes
git clone https://github.com/bugltd/ComfyLab-Pack.git
cd ComfyLab-Pack
pip install -r requirements.txt
Restart after. No models to download; the pack's requirements (opencv-python, pyyaml, jsonschema, and a few small ones) install cleanly.
Gotchas
- Cropping eats edges. If you can't lose content, letterbox the image first or feed one already near the budget.
megapixelsof 0 is legal and dumb. You'll get a 1×1-ish sliver. Stay at 0.1 or above in practice.- It never upscales. Smaller-than-target images pass straight through. If you need "make it exactly this size either direction," this isn't the node - that's the core
ImageScaleToTotalPixels.
For a node with one job, it's refreshingly hard to misuse. Set a budget, wire it in front of whatever's picky about input size, move on.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| downscale_method | COMBO | lanczos | downscale method |
| megapixels | FLOAT | 1.00–16 | target size in megapixels |
| multiple_of | INT | 0 | if > 0, ensure the dimension are multiple of this number |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | downscaled image |
| width | INT | width |
| height | INT | height |
| actual_size | FLOAT | actual size in MP |