Nodes/ComfyUI-Desert-Pixel-Nodes/DP Resize Image And Mask
ComfyUI Node

DP Resize Image And Mask

Resize both together so they never desync

By DesertPixelAi·Created 2 years ago·Updated about a year ago· 25
DP Resize Image And Mask
  • image
  • mask_opt
  • image
  • mask
width512
height512
keep_proportionsfalse
upscale_method
crop
export_image_with_alphafalse
force_rgb_outputfalse

Resizing an image and its mask separately is a classic way to quietly break an inpainting workflow - the two end up at mismatched sizes or slightly different aspect ratios and suddenly your mask doesn't line up with what it's supposed to cover. This node resizes both in one operation, with the same settings, so they stay perfectly aligned. If you work with masks at all, it's a small node that saves a recurring headache.

It's an image utility in DesertPixelAi's Desert Pixel pack.

How it works

You give it an image and, optionally, a mask_opt. It resizes them together to your target width and height using a shared upscale_method and crop setting, and returns the matched pair.

  • upscale_method - nearest-exact, bilinear, area, bicubic, lanczos. lanczos is the quality pick for downscaling; bilinear/bicubic are fine general choices; nearest-exact preserves hard edges (and is the honest choice for masks you don't want feathered).
  • keep_proportions - when on, it respects the source aspect ratio instead of stretching to the exact width/height.
  • crop - disabled or center. Center-crop fills the target dimensions without distortion by trimming the overflow.
  • export_image_with_alpha and force_rgb_output - control whether the output carries an alpha channel or is forced to flat RGB.

Outputs are image and mask, both at the new size. The mask output is empty/passthrough if you didn't feed one in.

The inputs and outputs that matter

width, height, and upscale_method are the everyday three. Add keep_proportions + crop: center when the source aspect ratio doesn't match your target and you'd rather crop than squash. Feed the mask into mask_opt and it rides along automatically.

How to install it

ComfyUI Manager: search Desert Pixel, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/DesertPixelAi/ComfyUI-Desert-Pixel-Nodes

Restart ComfyUI. No downloads. Under the DP category.

Common issues & troubleshooting

The mask output is blank. mask_opt is optional - if you didn't connect one, there's nothing to resize. Wire your mask in.

The image looks stretched. With keep_proportions off and a target aspect ratio different from the source, it squashes to fit. Turn keep_proportions on, and use crop: center if you need it to exactly fill the target dimensions.

Mask edges got soft and inpainting bled. Smooth interpolation (bilinear, lanczos) feathers a mask's edges, which can be fine or can cause bleed depending on your workflow. If you need crisp mask boundaries, resize the mask with nearest-exact. (This node applies one method to both, so if image and mask genuinely need different treatment, resize them in separate passes.)

Alpha channel confusion. If a downstream node complains about channel count, toggle force_rgb_output on to guarantee flat RGB, or export_image_with_alpha if you specifically need the transparency preserved.

CategoryDP/image

Inputs (9)

NameTypeDefaultDescription
imageIMAGE
widthINT51264–8192
heightINT51264–8192
keep_proportionsBOOLEANfalse
upscale_methodCOMBO5 options: nearest-exact, bilinear, area, bicubic, lanczos
cropCOMBO2 options: disabled, center
export_image_with_alphaBOOLEANfalse
force_rgb_outputBOOLEANfalseConvert RGBA to RGB for compatibility with nodes like RMBG
mask_optoptMASK

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK