DP Resize Image And Mask
Resize both together so they never desync
- image
- mask_opt
- image
- mask
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.lanczosis the quality pick for downscaling;bilinear/bicubicare fine general choices;nearest-exactpreserves 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-disabledorcenter. Center-crop fills the target dimensions without distortion by trimming the overflow.export_image_with_alphaandforce_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.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width | INT | 51264–8192 | — |
| height | INT | 51264–8192 | — |
| keep_proportions | BOOLEAN | false | — |
| upscale_method | COMBO | 5 options: nearest-exact, bilinear, area, bicubic, lanczos | |
| crop | COMBO | 2 options: disabled, center | |
| export_image_with_alpha | BOOLEAN | false | — |
| force_rgb_output | BOOLEAN | false | Convert RGBA to RGB for compatibility with nodes like RMBG |
| mask_optopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |