A zero‑nonsense ComfyUI node that resizes every incoming image (or batch) so the final resolution hovers around one million pixels—while respecting the original aspect ratio and snapping both dimensions to multiples of 64. Perfect for pipelines that need a predictable VRAM footprint without destroying composition.
- Stable VRAM budgeting – 1 Mpx keeps you under GPU‑meltdown territory for SDXL & friends.
- Clean, divisible dims – Multiples of 64 mean you never hit those “size must be divisible by 8/16/64” errors again.
- No potato quality – Pick from
nearest,bilinear,bicubic, orarea; the node auto‑anti‑aliases when down‑sampling with the smooth modes. - Batch‑safe – Works on full tensors shaped
(B, H, W, C); each frame is resized independently. - Tenos‑grade math – Two rounding strategies duel it out under the hood; whichever lands closer to 1 Mpx wins. (It’s nerdy—see the code.)
-
Drop it Save
tenos_image_resize_target_pixels.pyinto:ComfyUI/custom_nodes/(Create the folder if it doesn’t exist.)
-
Restart ComfyUI – The node shows up under TenosNodes ➜ Image Processing ➜ Tenos Resize to ~1M Pixels.
-
Wire it in – Feed any image tensor; enjoy harmony.
| Field | Type / Options | Notes |
|---|---|---|
| Input – image | IMAGE |
4‑D tensor (B,H,W,C) |
| Input – interpolation | One of area, bicubic, bilinear, nearest |
Defaults to bicubic if you pass something weird |
| Output – image | IMAGE |
Resized tensor, same batch size |
TARGET_TOTAL_PIXELS = 1_000_000– The sweet spot.DIMENSION_MULTIPLE = 64– Keeps UNet / VAE happy.
- Compute the ideal height and width for exactly 1 Mpx at the original aspect ratio.
- Try rounding height first → recalc width → snap both to /64.
- Try rounding width first → recalc height → snap.
- Whichever candidate lands closer to 1 Mpx wins; ties go to option 1.
Edge‑cases handled:
- Zero / negative dims fall back to a 64 × 64 stub.
- If the image already matches the target dims, it passes through untouched (zero extra ops).
- Anti‑aliasing toggles itself only when you’re down‑scaling with
bilinearorbicubic.
Loader → Tenos Resize to ~1M Pixels → Txt2Img → Save PNG
Need a weird upscale? Just chain it before a separate upscale node—this keeps your latent generation predictable.
- Area and nearest are cheapest but can look crunchy.
- Bicubic is slowest but usually prettiest—especially for photo content.
- On big batches, the node loops per‑image, so your VRAM stays flat but it scales CPU‑side.
Created with love from Tenos.ai