comfyui-image-crop-by-mask-multiple
A ComfyUI custom node based on KJNodes' Image Crop By Mask And Resize, with one added feature: a multiple input that forces the output image, mask, and bbox dimensions to be an exact multiple of a value you choose (e.g. 8, 16, 32, 64), instead of the fixed multiple-of-16 rounding in the original node.
ComfyUI Image Crop By Mask And Resize (Multiple)
A ComfyUI custom node based on KJNodes' Image Crop By Mask And Resize, with one
added feature: a multiple input that forces the output image, mask, and bbox
dimensions to be an exact multiple of a value you choose (e.g. 8, 16, 32, 64), instead
of the fixed multiple-of-16 rounding in the original node.
Why
Many models (video/image diffusion pipelines, VAEs, etc.) require input dimensions to be aligned to a specific step size. This node lets you set that step size directly instead of being locked to 16.
Node
Image Crop By Mask And Resize (Multiple)
Inputs:
image,mask— standard ComfyUI IMAGE / MASK inputsbase_resolution— target resolution for the longer side of the resizepadding— extra pixels around the mask's bounding boxmin_crop_resolution/max_crop_resolution— clamp the raw crop box size before resizingmultiple— output width/height (and bbox size) are rounded up to the nearest multiple of this value
Outputs:
images,masks,bbox
Note: width and height are rounded to multiple independently, so on some aspect
ratios the resize step can introduce slight stretching. This trade-off keeps the node
simple and its output size predictable and bounded — it will never produce runaway
resolutions regardless of the mask's aspect ratio.
Installation
Option A: ComfyUI Manager
Search for "Image Crop By Mask And Resize (Multiple)" in ComfyUI Manager's custom node browser and install directly.
Option B: Manual
cd ComfyUI/custom_nodes
git clone https://github.com/mo-akkakk/comfyui-image-crop-by-mask-multiple.git
Restart ComfyUI.
Credit
Based on the "Image Crop By Mask And Resize" node from KJNodes by kijai.
License
MIT — see LICENSE.