Mira Image Upscale Calculator
Pick a target size, set a VRAM budget — this node does the math and the downscaling
- image
- processed_image
- new_upscale_factor
Every serious upscale pipeline has the same nagging question in the middle of it: "how big can I actually afford to go?" You set an upscale factor, but the real constraint is megapixels - a 2× on a 4K source is a different animal than 2× on a 512². Mira Image Upscale Calculator is a small utility that answers the question: give it your image and a target factor, tell it your megapixel budget, and it hands back the resized image plus the actual upscale factor you'll really get. The second output is the part that makes it useful in a graph - downstream math can consume it instead of hard-coding a number.
It also fixes a sneaky problem before it starts: it center-crops the input to the pixel_alignment grid first. A misaligned source is the classic cause of VAE artifacts at tile edges, so this node normalizes the input before any resize happens, with a console note showing the crop.
The inputs
- image - the input IMAGE.
- target_upscale_factor (default 2, up to 16) - how much bigger you want it, relative to the original.
- limit_megapixels (default 4) - the hard budget. If the target size would blow past it, the image gets downscaled to fit.
- pixel_alignment (default 8) - alignment grid for resizing.
- downscale_method (default bicubic) - how it shrinks when the budget is exceeded.
lanczosis the sharper choice if you care.
Two outputs: processed_image (the aligned, budget-limited image) and new_upscale_factor (the actual factor after clamping - this is what you wire into downstream nodes).
How it works, briefly
From the source: it converts limit_megapixels to a pixel count (limit × 1024 × 1024), center-crops to the alignment grid, then checks whether the target size fits. If it does, new_upscale_factor is your requested factor and the image passes through (aligned). If not, it downscales the input so the target lands at the budget, and reports the shrunken factor - which is the honest number your tiling nodes should use.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/mirabarukaso/ComfyUI_MiraSubPack
or search "MiraSubPack" in ComfyUI Manager and restart. No extra dependencies.
Where it fits
In the Mira ITU loop, it's the sane front-end: run your upscale-calculator, feed the clamped factor into LatentUpscaleAndCropTiles (or your pixel upscaler), and let the tiles fall where they may. Standalone, it's a decent "sanity-check my upscale target" node - especially if you've ever loaded a monster image and had the VAE throw a fit over misaligned dimensions. That alignment crop alone justifies it in a beginner's graph: one less way for a mystery artifact to sneak in.
The one thing to keep in mind: it reports the factor relative to the original input, not to whatever already-resized state your image arrived in. Feed it the image you're actually measuring from, and trust new_upscale_factor over your own arithmetic.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image. | |
| target_upscale_factor | FLOAT | 2.01–16 | Target upscale factor relative to the ORIGINAL image size. |
| limit_megapixels | FLOAT | 4.01–64 | Maximum allowed megapixels for the input image. If exceeded, image is downscaled to fit. |
| pixel_alignment | INT | 88–128 | Pixel alignment for resizing. |
| downscale_method | COMBO | bicubic | Method for downscaling if limit is exceeded. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| processed_image | IMAGE | — |
| new_upscale_factor | FLOAT | — |