Redraw Size Calculator
Clamp any input image into your model's happy resolution band before you redraw it
- image
- mask
- image_resized
- mask_resized
- image_original
- mask_original
- width_resized
- height_resized
- width_original
- height_original
- target_megapixels
Mask-based redrawing has one annoying problem that's always your job: feeding the model an image at a sensible resolution. A 4K screenshot is too big for most models to redraw directly; a 300px crop is too small for detail. Redraw Size Calculator (from comfyui-ysnodes) automates the middle - you tell it the minimum and maximum megapixels your model is comfortable with, and it scales any incoming image (and its mask) to land inside that band, snapped to VAE-safe multiples of 8.
It's a subgraph lifted from stock ComfyUI pieces - GetImageSize → total pixel math → clamp_megapixels → ImageScaleToTotalPixels - collapsed into one node. Which is exactly what the pack is: common workflows re-bundled so you don't rebuild them by hand every time.
How it works
The node reads the image's dimensions, computes total pixels, clamps that against your chosen min and max megapixel values, then resizes the image (and mask, if connected) to the clamped target. Images below the min get upscaled; images above the max get downscaled; images already inside the band pass through untouched. The mask follows the image path exactly, so they always match.
The inputs that matter
You mostly set two things:
min_presetandmax_preset- 14 built-in presets tied to real model resolutions, from0.25 MP (512×512 - SD1.5)up through2.25 MP (1536×1536 - 2xSDXL), with SDXL's 1024×1024 (1.00 MP) and Flux's 1.50 MP in between. Pick the band for whatever model you're sampling with.min_megapixels_override/max_megapixels_override- set these to a non-zero float and they beat the presets. Handy when your exact resolution isn't in the list.
upscale_method defaults to lanczos and is fine as-is. The mask input is optional - it comes back as zeros if you don't connect one.
The outputs
Nine of them, but the useful ones are: image_resized and mask_resized (feed these to your sampler's latent path), plus image_original / mask_original if you want the untouched version downstream, and target_megapixels - a debug output showing what the clamp actually picked. width_resized / height_resized are handy for chaining into size-picker nodes so downstream resolution matches what this node produced.
Installing it
Same zero-dependency install as every node in this pack - nothing to download but the code.
cd ComfyUI/custom_nodes
git clone https://github.com/MrYassinox/comfyui-ysnodes.git
or search comfyui-ysnodes in ComfyUI Manager and restart. It lives under YSNodes/image.
Where it fits, and where it doesn't
This is the resolution-control layer for the classic masked-inpainting stack - the one that still uniquely gives you bit-identical unmasked pixels and full-resolution detail inside the mask, which instruction-edit models like Kontext and Qwen-Image-Edit can't. Use Redraw Size to normalize your input before encoding, then inpaint at your model's native resolution. Where it doesn't fit: this node never touches a VAE and doesn't output latents, so you still need a VAEEncode (or the pack's ImageScaleToTotalPixels) between it and a KSampler. Think of it as the sizing brain of a redraw workflow, not the whole thing.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image to resize for redrawing. | |
| upscale_method | COMBO | lanczos | Interpolation method used when scaling image and mask. |
| min_preset | COMBO | 0.25 MP ( 512x 512 - SD1.5) | Preset minimum MP. Images below this are upscaled. Ignored when min_megapixels_override > 0. |
| min_megapixels_override | FLOAT | 0.000–64 | Override min preset. Set to 0 to use preset. Example: 0.26 ~ 512x512px. |
| max_preset | COMBO | 1.50 MP (1024x1536 - Flux) | Preset maximum MP. Images above this are downscaled. Ignored when max_megapixels_override > 0. |
| max_megapixels_override | FLOAT | 0.000–64 | Override max preset. Set to 0 to use preset. Example: 1.5 ~ 1024x1536px. |
| maskopt | MASK | Optional mask resized to match image_resized exactly. |
Outputs (9)
| Name | Type | Description |
|---|---|---|
| image_resized | IMAGE | — |
| mask_resized | MASK | — |
| image_original | IMAGE | — |
| mask_original | MASK | — |
| width_resized | INT | — |
| height_resized | INT | — |
| width_original | INT | — |
| height_original | INT | — |
| target_megapixels | FLOAT | — |