fit-mask-to-image
ComfyUI node for fitting masks to image dimensions with automatic batch size adjustment
Package profile
- Status
- Verified
- Publisher
- @DazzleNodes
- Source
- GitHub
README
ComfyUI Fit Mask to Image
Python 3.10+ ComfyUI Registry GitHub release License: MIT
Automatically resizes masks to match image dimensions for seamless inpainting workflows. Replaces a 10-node workflow chain with a single, efficient node.
Overview
This node solves a common inpainting problem: when your KSampler output dimensions (i.e. 960x960) no longer match your input (i.e. 958x958) mask dimensions due to the KSampler outputs being divisible by 8. This is also helpful for workflows where masks and images come from different sources or when upscaling changes dimensions.
Features
- One-Node Solution: Replaces 10-node workflow with single node
- Smart Dimension Matching: Automatically scales masks to match image dimensions
- Missing Mask Handling: Auto-generates masks when none provided (default: entire image visible)
- Multiple Outputs: Fixed mask, preview image, debug mask, and masked latent
- Inpainting Ready: Direct integration with KSampler via latent output
- Debug Information: Detailed info output showing dimension changes
- Nearest-Exact Scaling: Preserves mask quality during resize
Prerequisites
- ComfyUI installation
- Python 3.10+ (or ComfyUI's embedded Python)
- No additional dependencies (uses ComfyUI's PyTorch, PIL, numpy)
Installation
ComfyUI Registry (Recommended - Coming Soon)
The easiest way to install is through the ComfyUI Registry:
- Open ComfyUI Manager in your ComfyUI interface
- Search for "DazzleNodes" ("Fit Mask to Image" isn't a standalone node)
- Click Install and restart ComfyUI
The node will appear under: DazzleNodes → Fit Mask to Image
Alternatively, use the command line:
comfy node install fit-mask-to-image
Git Clone
cd ComfyUI/custom_nodes
git clone https://github.com/DazzleNodes/fit-mask-to-image.git
Then restart ComfyUI or use Manager → Refresh Node Definitions.
Manual Installation
- Download the latest release and extract to
ComfyUI/custom_nodes/fit-mask-to-image/ - Restart ComfyUI
- Find the node in: DazzleNodes → Fit Mask to Image
Part of DazzleNodes Collection
This node is also included in the DazzleNodes collection. If you install DazzleNodes, you automatically get this node along with other useful nodes.
Usage
Basic Workflow
- Add "Fit Mask to Image" node to your workflow (found under "DazzleNodes")
- Connect your source IMAGE (for dimension reference)
- Connect your MASK (to fix dimensions)
- Set missing_mask parameter (default:
pass_through- preserves original behavior) - Optionally connect a LATENT for inpainting workflows
Missing Mask Handling
The missing_mask parameter controls what happens when no mask is connected or mask is empty:
- pass_through (default): Process empty mask as-is (original behavior)
- all_visible: Creates white mask (entire image visible)
- all_hidden: Creates black mask (entire image masked)
- error: Fails with error message (useful for debugging)
Outputs
- fixed_mask: Final mask with corrected dimensions (from alpha channel)
- preview_image: RGB+alpha merged image for visual verification
- info: Text showing original→target dimensions and processing status
- masked_latent: Latent with mask applied (if lat
Nodes in this pack
1 node
Nodes in this pack
1 node- FitMaskToImage
Sources
3 sources
Sources
3 sourcesVerified Oct 2
Verified Oct 2
Source excerpts
1 excerpt
Source excerpts
1 excerptSource context: Repo DazzleNodes/fit-mask-to-image
