ComfyUI Node

AdvResize

The resize node that remembers your mask

By criskb·Created 7 months ago·Updated 5 months ago· 0
AdvResize
  • image
  • mask
  • image
  • mask
  • resize_info
mode
target_width1024
target_height1024
side_length1024
interpolation
round_mode
align_to_multiple1
anchor
allow_upscaletrue
pad_r0.00
pad_g0.00
pad_b0.00
pad_a1.00
mask_pad_value0.00

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_side
  • target_width / target_height - or side_length if you're in long/short-side mode
  • align_to_multiple - default 1, set to 8 or 64 for model-friendly dims
  • anchor - 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 it
  • mask - the resized MASK, still matching the image pixel-for-pixel
  • resize_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.

CategoryMKRShift Nodes/Utility/Resize

Inputs (16)

NameTypeDefaultDescription
imageIMAGE
modeCOMBO5 options: fit, fill_crop, stretch, long_side, short_side
target_widthINT10241–32768
target_heightINT10241–32768
side_lengthINT10241–32768
interpolationCOMBO6 options: lanczos, bicubic, bilinear, hamming, box, nearest
round_modeCOMBO3 options: round, floor, ceil
align_to_multipleINT11–512
anchorCOMBO9 options: center, top_left, top, top_right, left, right, +3
allow_upscaleBOOLEANtrue
pad_rFLOAT0.000–1
pad_gFLOAT0.000–1
pad_bFLOAT0.000–1
pad_aFLOAT1.000–1
mask_pad_valueFLOAT0.000–1
maskoptMASK

Outputs (3)

NameTypeDescription
imageIMAGE
maskMASK
resize_infoSTRING