Nodes/ComfyUI-SimpleMegapixels/Image Resize (Megapixels)
ComfyUI Node

Image Resize (Megapixels)

Resize Your Image to Any Megapixel Count With One Number

By ai-joe-git·Created about 16 hours ago·Updated about 16 hours ago· 0
Image Resize (Megapixels)
  • image
  • IMAGE
◄megapixels1.00►
◄upscale_method▾►
◄round_to8►

If you've spent any time in ComfyUI, you've had this moment: you want an image to be "about 1 megapixel" and you end up doing square roots in your head, then nudging numbers until they're divisible by 8. SimpleMegapixels deletes that. You give it a target area, it gives you back the right dimensions, aspect ratio intact.

That's the whole node. One input, one output - and it's honest about it.

What it is and when you'd reach for it

Models don't care about your image being 1024×1024. They care about roughly how many pixels are in it. Most 2026 architectures take anything inside a 1–2MP band and degrade softly outside it, but SDXL was trained on a fixed list of ratios (1024×1024, 1152×896, 1344×768 and so on), and above native resolution the old failure modes return: repeated patterns, stretched limbs, twin torsos.

So "resize this" is almost never about a specific width. It's about a budget: make this fit in 1MP, or make this big enough for a SeedVR2 pass. That's the job here. This is the pixel rung of upscaling - pure interpolation. It adds no content and can't hallucinate, which is why it's fast and boring, and also why you shouldn't point it at a soft image expecting it to invent anything.

How it works

The mechanism is three lines of math and one ComfyUI utility call. It works out the current megapixel count of the incoming image, takes sqrt(target / current) to get a single scale factor, applies that to both sides, rounds each side to your chosen multiple, and hands the result to comfy.utils.common_upscale.

Rounding is the part that matters for diffusion work. round_to = 8 puts output dimensions on multiples of 8, the safe convention for latent models that downsample by 8. Pick 64 if you're inside an architecture that wants dimensions divisible by 64 (Flux among them). That's the only reason those options exist.

The README's example is worth internalizing: 1344×768 (~1.03MP) at megapixels = 4.0 scales by √(4.0 / 1.03) ≈ 1.97 and comes out 2648×1512. You land near the target, not on it.

The inputs and the output

Everything the brief reports is what's actually there - image, megapixels, upscale_method, round_to, and a single IMAGE output. Three of the four matter:

  • megapixels (default 1.0, 0.01–100 in steps of 0.01). This is area, not width, and it's the one people misread. 1.0 gives you 1024×1024 only for a square input; on a 16:9 image you get roughly 1333×750.
  • round_to (1 / 8 / 16 / 32 / 64, default 8). Leave it at 8 unless your model family wants otherwise. 1 exists, but odd dimensions are a reliable way to make latent pipelines grumpy for no benefit.
  • upscale_method (lanczos, bicubic, bilinear, area, nearest-exact). The source lists them in that order and declares no default, which in ComfyUI means you get lanczos - the right call for photos. Use nearest-exact for pixel art or masks, and area when you're aggressively downscaling, since it averages rather than samples.

Batch is preserved - feed it eight images, get eight back, all resized coherently. Wire the output into a SaveImage, a VAE Encode before a sampler, a ControlNet preprocessor, or whatever upscaler you're stacking after it.

Install

Nothing to download. The pack is one node, requirements.txt is empty, pyproject.toml declares zero dependencies, and it only imports torch and comfy.utils. No model files, no CUDA extras.

ComfyUI Manager: search SimpleMegapixels and restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ai-joe-git/ComfyUI-SimpleMegapixels

Restart ComfyUI and the node appears under image/upscaling as "Image Resize (Megapixels)". It's published to the Comfy Registry under the ai-joe-git publisher too, so the Manager route works without cloning.

Things people get wrong

Expecting detail. This is interpolation. Upscaling a 0.3MP soft source to 4MP with Lanczos gets you a bigger soft image. Detail is a generative job: ESRGAN-lineage models, or SeedVR2, the community's detail answer since late 2025.

Not knowing it's really a prep node. Its most useful trick is the opposite of upscaling. Comfy Org's own handbook recommends downscaling to about 0.35 megapixels before a SeedVR2 pass, because when a source is soft rather than small there's no detail at full resolution to recover - drop it to match its real sharpness and let the restorer rebuild. This node hits that number cleanly. It's also the "normalise everything into the 1MP band" step that template workflows use the stock ImageScaleToTotalPixels node for.

Rounding surprises. The node floors dimensions at the rounding value, so you never get a zero-width tensor - but with round_to = 64 a small input can come back as 64×64 instead of shrinking further.

Node doesn't appear after install. Almost always a stale UI or a server that hasn't actually restarted. Hard-refresh the tab and restart ComfyUI; if it's still missing, check the console for an import error rather than reinstalling.

One caveat: this is a new, single-node pack from a small author, and core ImageScaleToTotalPixels does something similar. What you're buying is ergonomics. If your resize chain already works, don't rebuild it.

Categoryimage/upscaling

Inputs (4)

NameTypeDefaultDescription
imageIMAGE—
megapixelsFLOAT1.000.01–100—
upscale_methodCOMBO5 options: lanczos, bicubic, bilinear, area, nearest-exact
round_toCOMBO85 options: 1, 8, 16, 32, 64

Outputs (1)

NameTypeDescription
IMAGEIMAGE—