AdvResize
The resize node that remembers your mask
- image
- mask
- image
- mask
- resize_info
Plain resize nodes are everywhere in ComfyUI, but almost all of them drop your mask on the floor or round to whatever dimension happens to come out. AdvResize is the one that treats image and mask as a pair and gives you production control over both - which is exactly what you want the moment you're prepping plates for a model with strict dimension requirements or building a workflow where an inpaint region has to stay glued to its image through a resize.
It comes from MKRShift Nodes, the broad production-focused pack by Cris K B (criskb). It's a pure-image utility, so it brings zero model downloads and no extra Python dependencies along with it.
How it works
AdvResize is a PIL-based resizer with five modes. fit letterboxes into the target canvas, fill_crop scales up and crops away the overflow, stretch just smashes it to target, and long_side / short_side ignore width and height entirely and instead scale so that the longer (or shorter) edge equals side_length. The useful nuance: in the source, fill_crop falls back to letterboxing when allow_upscale is off - so if your source is smaller than the target, "crop" quietly becomes "pad" rather than upscaling.
The anchor (nine positions from top-left to bottom-right) decides where the image sits inside the canvas when it doesn't fill it, and where the crop window cuts from. align_to_multiple snaps both output dimensions to a multiple of your number - set it to 8 and every result comes out divisible by 8, which is the kind of thing that keeps SDXL- and Flux-era models from throwing dimension errors. interpolation gives you the full resampling family (lanczos, bicubic, bilinear, hamming, box, nearest) - lanczos is a solid default for photos, nearest if you're resizing pixel art and want to keep hard edges.
The inputs that matter
You'll touch four of these most days:
mode- fit / fill_crop / stretch / long_side / short_sidetarget_width/target_height- orside_lengthif you're in long/short-side modealign_to_multiple- default 1, set to 8 or 64 for model-friendly dimsanchor- where the pad or crop centers from
The pad color inputs (pad_r/g/b/a) control the letterbox fill, and mask_pad_value controls what the resized mask's empty regions become (0 = transparent/black mask, 1 = fully covered). Pass a MASK into the optional input and it comes out the other side resized with the same mode, same anchor, same alignment - that lockstep is the whole reason this node exists.
Outputs
image- the resized IMAGE, wired onward to whatever consumes itmask- the resized MASK, still matching the image pixel-for-pixelresize_info- a STRING summarizing what happened (mode, in/out dims, anchor, alignment), handy for logging or feeding a text-preview node
Installation
cd ComfyUI/custom_nodes
git clone https://github.com/criskb/MKRShift_Nodes
Then restart ComfyUI. Or install through ComfyUI Manager - search for "MKRShift Nodes" and hit install. The pack has no requirements.txt pip dependencies for this node, so there's nothing extra to pull; ffmpeg is only needed for the pack's video/audio nodes, not this one.
Common issues
Where people get burned: forgetting that fill_crop won't upscale past 1:1 unless allow_upscale is on, and then wondering why their 512px plate came out with black bars at 1024. And mismatched pad semantics - if your letterbox is white but your mask pad is 0, a downstream inpaint will happily fill the bars as if they were empty canvas. If you're feeding the result into a ComfyUI ImageResize-free chain that demands exact multiples, align_to_multiple is the difference between a clean run and a "pixels out of range" sampler error. It's not flashy, but it's the node you stop noticing once it's in the graph - which is exactly what you want.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mode | COMBO | 5 options: fit, fill_crop, stretch, long_side, short_side | |
| target_width | INT | 10241–32768 | — |
| target_height | INT | 10241–32768 | — |
| side_length | INT | 10241–32768 | — |
| interpolation | COMBO | 6 options: lanczos, bicubic, bilinear, hamming, box, nearest | |
| round_mode | COMBO | 3 options: round, floor, ceil | |
| align_to_multiple | INT | 11–512 | — |
| anchor | COMBO | 9 options: center, top_left, top, top_right, left, right, +3 | |
| allow_upscale | BOOLEAN | true | — |
| pad_r | FLOAT | 0.000–1 | — |
| pad_g | FLOAT | 0.000–1 | — |
| pad_b | FLOAT | 0.000–1 | — |
| pad_a | FLOAT | 1.000–1 | — |
| mask_pad_value | FLOAT | 0.000–1 | — |
| maskopt | MASK | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| resize_info | STRING | — |