Image Scale Range From MP (CRT)
Keep every image in a batch between two megapixel bounds
- image
- image
- width
- height
Upscale is a one-way street: once an image is too big for your workflow, scaling it back down loses the point. ImageScaleRangeFromMp is the node that thinks in megapixels instead - you give it a floor and a ceiling, and it normalizes whatever comes in to sit between them. In a batch where inputs vary from tiny thumbnails to wallpapers, it's the difference between a sampler that chokes on mixed resolutions and one that never notices.
The mechanism, and why it's smart about it
It measures the incoming image, and:
- below
min_megapixels→ upscales to the floor - above
max_megapixels→ downscales to the ceiling - already in range → passes through untouched
The scaling is the part worth reading twice: it resizes both axes by one uniform factor (so no aspect-ratio stretch), then does the final quantization with a centered crop, never a second resize. That crop-first approach means the output stays step-aligned without the softness a second interpolation pass would add. Small downside to know: because it crops down, the final megapixels can land slightly below the bound you asked for.
The inputs
image- yourIMAGEtensor.upscale_method-nearest-exact,bilinear,area,bicubic, orlanczos. For downscaling,areais the classic pick; for upscaling,lanczos/bicubiclook better thannearest.min_megapixels- floor (default 0.25).max_megapixels- ceiling (default 1.0).resolution_steps- the step to quantize the final dimensions to (default 1, so no quantization). Set it to 8 or 16 if your sampler needs multiples.
Outputs: the resized image, plus width and height as INTs - the pair you can wire into a KSampler's EmptyLatentImage or into CRT's own Resolution (CRT) world.
Where you'd reach for it
Mixed-resolution batches, mostly - a folder of reference images, video frames, or scraped data where every input is a different size and the downstream model has a sweet spot. It's also a handy normalization layer before an upscale pass: clamp inputs to a sane MP range so the heavy model only sees what it's good at. It is not a quality upscaler - it's a range normalizer with good taste.
Gotchas
- Cropping, not stretching. If you need every pixel preserved, this will center-crop edges instead. Know that going in.
- Tiny inputs get upscaled with real interpolation.
min_megapixelsabove the source size means invented pixels, not recovered detail - keep the floor close to your actual content. - Step 1 = no quantization. The default
resolution_stepsof 1 is fine for most downstream nodes, but model-specific multiples (8/16/64) are your job to set.
Install CRT-Nodes via ComfyUI Manager (CRT-Nodes) or git clone https://github.com/plugcrypt/CRT-Nodes.git into custom_nodes, install requirements.txt, restart.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| upscale_method | COMBO | 5 options: nearest-exact, bilinear, area, bicubic, lanczos | |
| min_megapixels | FLOAT | 0.250.01–64 | — |
| max_megapixels | FLOAT | 1.000.01–64 | — |
| resolution_steps | INT | 11–256 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| width | INT | — |
| height | INT | — |