Image and Mask Resize
Resize the pixels and the mask, together
- image
- mask
- target
- IMAGE
- MASK
Every masking workflow has this moment: you inpaint or composite at one resolution, and then you need the image and its mask to come along at a new size - and they must stay aligned. Resize them separately and a one-pixel drift between image and mask turns into a misaligned inpaint. UC_ImageAndMaskResize is the node that does both at once, which is exactly the kind of boring, correct utility that saves you a debugging session.
It's the pack's take on the classic "resize image and mask together" node, with a couple of nice details: it can resize to a reference image's dimensions instead of explicit numbers, it has a center-crop option, and it'll blur the resized mask for you.
How it works
You feed it image and mask. Target dimensions come from one of two places: an explicit width/height pair (optional, defaulting to 512 each), or a target reference image whose width and height are used whenever the explicit dimensions aren't connected. The image is resized with resize_method (default lanczos - pick nearest-exact if you're resizing pixel-art or a hard matte and want crisp edges), and the mask is resized the same way so the two stay pixel-locked.
Two knobs matter for masks specifically:
crop-disabledstretches directly to the target dimensions;centercrops while resizing, keeping the center content. If you're changing aspect ratio,centeris usually what you want for a subject.mask_blur_radius- a Gaussian blur applied to the resized mask (default 0 = off). A few pixels of blur is the classic fix for hard mask edges that cause visible seams in composites.
Inputs and outputs
Required: image, mask. Optional: target, width, height. Outputs are IMAGE and MASK, matching the input pair, both at the same new size.
Installing it
ComfyUI Manager → search "ComfyUI-UtilsCollection", or:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
Restart. Pack deps are opencv-python and typing-extensions - no models, no API keys. It uses the newer ComfyExtension API, so keep ComfyUI current.
The trap: if you connect explicit width/height and a target image, the explicit values win (they "override the target image width/height"). It's easy to leave a stale 512×512 wired in from an earlier experiment and wonder why your 1024 target is being ignored. Disconnect the explicit inputs and let target rule, or vice versa - pick one source of truth.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| target | IMAGE | Reference image whose width and height are used when explicit dimensions are disconnected. | |
| resize_method | COMBO | lanczos | Interpolation used to resize the image to the target dimensions. |
| crop | COMBO | disabled | Center crops while resizing when enabled; disabled stretches directly to the target dimensions. |
| mask_blur_radius | INT | 00–256 | Gaussian blur radius applied to the resized mask; zero disables blur. |
| widthopt | INT | 5121–16384 | Optional output width overriding the target image width. |
| heightopt | INT | 5121–16384 | Optional output height overriding the target image height. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |