Resize Image Megapixels (WepeNerd)
One dial, no cropping, no mental arithmetic
- image
- image
The problem it solves
Every checkpoint has a resolution it was trained at, and going far off it costs you. The standing advice is "generate at native, upscale after" - which is correct and also pushes the problem one node downstream, because now you have an image at some arbitrary pixel count and you need it at a specific one. 0.35 MP because that's what the Comfy Org handbook asks for before a SeedVR2 pass. 1 MP because that's where the first pass of a hires-fix pair belongs. 2 MP because that's the top of your model's usable band.
Doing that by hand means working out sqrt(target / current) and multiplying two numbers, then redoing it when you get one of them wrong. This node is that arithmetic. It also handles the part people forget: divisibility.
What it actually does
The scale factor is sqrt(megapixels × 1e6 / (width × height)), applied to both dimensions. Each dimension is then rounded to the nearest multiple of your divisor - minimum one multiple, so you can't round yourself down to zero. Resampling runs through ComfyUI's own common_upscale, which means lanczos, bicubic, bilinear, nearest-exact and area behave exactly as they do in every other resize node. No cropping. Aspect ratio preserved as closely as rounding allows. And if the computed size already matches what came in, it hands the tensor straight back rather than resampling for nothing.
The divisor is the entire reason to pick this over core's ImageScaleToTotalPixels, which does the same megapixel job with no snapping at all. Set divisor to 8 for SDXL-and-earlier work (the VAE downsamples 8x per side) and 64 for Flux, which the community's own resolution notes list as "must be divisible by 64". Note the trade: at divisor 64 each axis can land up to 32 px off, so your real megapixel count may miss the target by a few percent. The author's own tooltip admits it - "Rounding may go above or below it" - and it's why 8 is the sane default rather than 64.
The inputs that matter
Four in, one out:
- image - the IMAGE or batch you're resizing.
- megapixels - float, 0.01 to 100, default 1. This is your intent. One megapixel is 1,000,000 pixels, so it means what you think it means.
- divisor - 2, 4, 8, 16, 32 or 64. This is your model's requirement, not your preference.
- upscale_method - lanczos (default), bicubic, bilinear, nearest-exact, area.
- image out (single IMAGE, batch preserved).
Most of the time you set megapixels and leave everything else. Two method switches are worth knowing: area when you're shrinking hard, because it averages the source pixels instead of point-sampling one and inventing a sharp edge that wasn't there, and nearest-exact for pixel art or anything you want to keep binary. Lanczos is the right default for everything in between.
Be honest about which job this is. It's the first of the three things people mean by "upscaling": more pixels. The source already has the detail, you just need it larger. Feed a soft or damaged image through it and you get bigger softness, because an interpolator cannot invent content. That's the SeedVR2/SUPIR branch of the tree.
Install
ComfyUI Manager, search ComfyUI-WepeNerd, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/WepeNerd/ComfyUI-WepeNerd.git
python -m pip install -r ComfyUI-WepeNerd/requirements.txt
Use the Python that runs ComfyUI. The requirements file is two lines - Pillow and numpy - and its own comment tells you not to install GPU wheels here because torch comes from ComfyUI. No model downloads, nothing compiled. The node shows up under WepeNerd/Image.
Where people get burned
The rounding. If you asked for 1 megapixel at divisor 16 and got 1,003,264, that's the node working as designed, not a bug - and if you feed that number into a SeedVR2 recipe expecting 0.35 MP exactly, expect the recipe to be approximate.
"No cropping" is a feature right up until it isn't. This node preserves whatever aspect ratio you hand it, so it will happily give you 3:1 for a model that was trained near 1:1. It fixes size, not composition. The Resize node family in core is where you crop; this one deliberately isn't.
And a bit of context worth having before you install: this pack is new - 0.1.0/0.2.0, September 2026 - and has essentially zero footprint in the image-gen subreddits. The same handle publishes LTX-2.3 LoRAs on Hugging Face, so the author is real, but nobody has stress-tested these nodes for you yet. The resize logic is about forty lines and readable, so the risk is low; just know you're an early user rather than one of a crowd.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| megapixels | FLOAT | 1.000.01–100 | Target image area; 1 MP = 1,000,000 pixels. Rounding may go above or below it. |
| divisor | COMBO | 8 | Round width and height to the nearest multiple of this number. |
| upscale_method | COMBO | 5 options: lanczos, bicubic, bilinear, nearest-exact, area |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |