Reimgsize
Resize to a megapixel budget, and stop thinking in width×height
- image
- image
- width
- height
- count
- channels
Reimgsize is the main node of this tiny pack, and the one that actually touches pixels. Give it an image, tell it roughly how many megapixels you want, and it resizes so the total pixel count lands at about img_size² while keeping the original aspect ratio - then snaps both dimensions to a multiple of GCD. It's the "total pixel count" school of resizing, and it's a more useful way to think than "width × height" once you've used it a few times.
The key mental model: img_size is not a width or height. It's the side of the square whose area you want. 1024 means ~1MP total, whatever the shape - a 16:9 image at img_size = 1024 comes out around 1344×768, not 1024×1024. That's the same family of behavior as core ComfyUI's ImageScaleToTotalPixels, the node Comfy Org's own SeedVR2 handbook suggests for dropping a soft source to 0.35MP before an upscale pass. Honest take: if all you want is "scale to total pixels," core already has that node. What Reimgsize adds is GCD snapping, an optional width/height override, and handy dimension metadata outputs - a convenience wrapper with model-friendly defaults, not a brand-new capability. The author is upfront that this pack is a beginner's self-use "repetitive wheel"; it's small, readable, and MIT-licensed.
How it works
The math is simple: aspect ratio comes from the source, height becomes int(sqrt(img_size² / aspect)), width becomes int(height * aspect), both rounded to the nearest GCD multiple. Then it hands off to comfy.utils.common_upscale - the same core helper the stock ImageScale node uses - with your chosen upscale method and crop behavior.
Inputs that matter
- img_size - the megapixel budget, default 1024 (~1MP), capped at 8192.
- GCD - the snap multiple, default 64 (matches Flux's "divisible by 64" habit). Set to 1 to disable snapping.
- upscale_method - nearest-exact, bilinear, area, bicubic (default), or lanczos. Same list as core ImageScale; pick nearest-exact for pixel art.
- crop_methods -
disabled(default) orcenter. This is where the subtle trap lives: snapping to a GCD multiple shifts the aspect ratio by a hair, and withdisabledthat hair shows up as a tiny stretch. Switch tocenterand it trims a thin strip off the edges instead - no distortion, a sliver of composition lost. - width / height (optional) - type one in or wire a value in and it overrides the computed dimension, deriving the other side from the aspect ratio. This is exactly where Resizebyratio from the same pack plugs in.
Outputs
image plus width, height, count, and channels. The batch count and channel count pass through untouched, which is handy when you're normalizing a mixed batch of images to a uniform megapixel count before VAE-encoding.
Where it fits in a workflow
Put it before VAE Encode for img2img, in front of ControlNet image conditioning, or right after Load Image when a downloaded workflow expects a model-native resolution. Keep expectations honest: like ImageScaleToTotalPixels, it can only reorganize the pixels you already have. It's geometry, not detail - a soft or damaged source stays soft, and that's what SeedVR2/SUPIR-class upscalers are for.
Install and gotchas
Pack-wide install is a clone or a Manager search for "comfyui_reimgsize" - no pip dependencies, no model files, restart after.
cd ComfyUI/custom_nodes
git clone https://github.com/MakkiShizu/comfyui_reimgsize.git
Two things trip people up. First, remembering img_size is a total-pixel spec and not a dimension - expect the output to be some other size than the number you typed. Second, the crop-method/GCD interaction above: if output looks subtly squished, that's crop_methods defaulting to disabled, and the fix is a one-click switch to center.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| upscale_method | COMBO | bicubic | 5 options: nearest-exact, bilinear, area, bicubic, lanczos |
| crop_methods | COMBO | disabled | 2 options: disabled, center |
| img_size | INT | 10241–8192 | — |
| GCD | INT | 641–512 | — |
| widthopt | INT | 1–8192 | — |
| heightopt | INT | 1–8192 | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| width | INT | — |
| height | INT | — |
| count | INT | — |
| channels | INT | — |