TenosResizeToTargetPixels
Resize Any Image to ~1M Pixels Without Killing the Aspect Ratio
- image
- IMAGE
Most models want a predictable amount of pixels. Feed them a 4K photo as an img2img reference and you don't get more detail - you get VRAM spikes, slower steps, and often no benefit at all, because a model trained around 1MP has nothing to do with the extra pixels. TenosResizeToTargetPixels is the one-node fix: it takes any image (or whole batch), resizes it so the total pixel count hovers near one million, keeps the aspect ratio intact, and snaps both dimensions to multiples of 64. Predictable VRAM, no stretched composition, no "size must be divisible by 8/16/64" errors.
It's a tiny utility from the Tenos-ai org, and honestly it's the kind of node you don't think about until it saves you an afternoon. The whole thing is one file, no model downloads, no dependencies beyond what ComfyUI already ships.
How it works
The math is refreshingly honest. The node computes the "ideal" height for exactly 1,000,000 pixels at your image's aspect ratio (ideal_height = sqrt(1_000_000 / aspect_ratio)), derives the width from it, then runs two rounding strategies in a duel: round height first and recalc width, then round width first and recalc height. Each candidate gets both dimensions snapped to the nearest multiple of 64, and whichever lands closest to 1M pixels wins. Ties go to the height-first path.
The edge cases are handled in code, not just the README:
- Zero or negative dimensions fall back to a 64×64 stub instead of crashing.
- If the image already matches the target dims, it passes through untouched - zero extra ops.
- Anti-aliasing only switches on when you're downscaling with
bilinearorbicubic, so upscaling doesn't get unnecessarily softened.
Batches are processed one image at a time and concatenated, so your VRAM stays flat even with a big batch - it just costs more CPU time.
The inputs that matter
Only two inputs, and you'll rarely touch one of them:
- image - an
IMAGEtensor in(B, H, W, C)form. Wire this straight from a Load Image node. It's the only required input that matters. - interpolation - an enum:
area,bicubic,bilinear, ornearest, defaulting tobicubicif you pass something weird.bicubicis the prettiest for photos;areaandnearestare cheaper but can look crunchy. This is the one knob a beginner actually sets.
The output is a single IMAGE with the same batch size, ready to feed a text-to-image model, an img2img pass, a reference/attention node, or a latent-space pipeline. Note it works in pixel space - feed it images, not latents.
Installing it
The repo is registered with the Comfy Registry (publisher id tenosai), so the clean path is ComfyUI Manager: search for Tenos Resize to 1 M Pixels and install, then restart ComfyUI. The node appears under TenosNodes → Image Processing. If you'd rather do it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/Tenos-ai/Tenos-Resize-to-1-M-Pixels
Then restart ComfyUI. That's the whole install - the code only uses torch.nn.functional.interpolate, and pyproject.toml lists zero extra dependencies. The README's older suggestion to drop the single .py file into custom_nodes/ also works (the file self-registers), but the clone/Manager route is tidier and keeps you on updates.
Where people get burned
The most common mistake is expecting this to be an upscaler. It is not - it's a geometric resize that normalizes resolution. If you want real added detail, chain a proper pixel upscaler (ESRGAN-style) or a generative pass after it. The standard trick: normalize to ~1MP here, generate, then upscale for output.
Also know what it's competing with: ComfyUI ships its own ImageScaleToTotalPixels, the one you see in the stock Flux 2 templates, which also normalizes to a total pixel count. The differentiator here is the multiple-of-64 guarantee - the stock node won't promise divisible dimensions, so you can still land on a size that trips a latent/ViT size check. For SDXL-and-friends pipelines (native ~1MP) or feeding references into Flux/2026-era models that degrade softly past 2MP, this is the version that removes one more class of "why won't it run" failures. It's a small, well-scoped node that does one job and does it without ceremony - exactly what a utility node should be.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| interpolation | COMBO | 4 options: area, bicubic, bilinear, nearest |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |