ComfyUI Node
TiledWan Inpaint Crop Improved
Advanced inpainting crop node that intelligently crops images around masked areas for optimal inpainting results. Features: - Batch processing with temporal consistency for video sequences - Automatic context area detection and expansion - Smart resizing with aspect ratio preservation - Optional pre-processing (resize, mask manipulation, outpainting extension) - Window size consistency across batches for video processing - Linear interpolation for smooth mask transitions in video sequences The node processes masks to find the optimal crop area, applies various preprocessing steps, and outputs cropped images ready for inpainting along with stitcher data for reconstruction.
TiledWan Inpaint Crop Improved
- image
- mask
- optional_context_mask
- stitcher
- cropped_image
- cropped_mask
◄downscale_algorithmbilinear►
◄upscale_algorithmbicubic►
◄preresizefalse►
◄preresize_modeensure minimum resolution►
◄preresize_min_width1024►
◄preresize_min_height1024►
◄preresize_max_width16384►
◄preresize_max_height16384►
◄mask_fill_holestrue►
◄mask_expand_pixels0►
◄mask_invertfalse►
◄mask_blend_pixels32►
◄mask_hipass_filter0.10►
◄extend_for_outpaintingfalse►
◄extend_up_factor1.00►
◄extend_down_factor1.00►
◄extend_left_factor1.00►
◄extend_right_factor1.00►
◄context_from_mask_extend_factor1.20►
◄output_resize_to_target_sizetrue►
◄output_target_width512►
◄output_target_height512►
◄output_padding32►
◄keep_window_sizefalse►
Categoryinpaint
Inputs (27)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image(s) to be processed. Can be a single image or batch of images for video processing. | |
| downscale_algorithm | COMBO | bilinear | Algorithm used when downscaling images. Bilinear provides good balance of quality and speed. |
| upscale_algorithm | COMBO | bicubic | Algorithm used when upscaling images. Bicubic provides better quality for upscaling. |
| preresize | BOOLEAN | false | Enable to resize the original image before processing. Useful for normalizing input sizes. |
| preresize_mode | COMBO | ensure minimum resolution | Mode for pre-resizing: minimum ensures image is at least the specified size, maximum caps the size, both enforces a range. |
| preresize_min_width | INT | 10240–16384 | Minimum width for pre-resize operation. Image will be upscaled if smaller. |
| preresize_min_height | INT | 10240–16384 | Minimum height for pre-resize operation. Image will be upscaled if smaller. |
| preresize_max_width | INT | 163840–16384 | Maximum width for pre-resize operation. Image will be downscaled if larger. |
| preresize_max_height | INT | 163840–16384 | Maximum height for pre-resize operation. Image will be downscaled if larger. |
| mask_fill_holes | BOOLEAN | true | Fill holes in the mask using iterative morphological operations. Helps create more complete masked regions. |
| mask_expand_pixels | INT | 00–16384 | Expand the mask by this many pixels before processing. Useful for including more context around masked areas. |
| mask_invert | BOOLEAN | false | Invert the mask so that masked areas become unmasked and vice versa. |
| mask_blend_pixels | INT | 320–64 | Create a soft transition zone around mask edges. Higher values create smoother blending during stitching. |
| mask_hipass_filter | FLOAT | 0.100–1 | Remove mask values below this threshold. Helps eliminate weak mask areas and noise. |
| extend_for_outpainting | BOOLEAN | false | Extend the image canvas for outpainting. Adds padding around the image for generating content beyond original boundaries. |
| extend_up_factor | FLOAT | 1.000.01–100 | Factor to extend image upward. 1.0 = no extension, 1.5 = 50% extension upward. |
| extend_down_factor | FLOAT | 1.000.01–100 | Factor to extend image downward. 1.0 = no extension, 1.5 = 50% extension downward. |
| extend_left_factor | FLOAT | 1.000.01–100 | Factor to extend image leftward. 1.0 = no extension, 1.5 = 50% extension leftward. |
| extend_right_factor | FLOAT | 1.000.01–100 | Factor to extend image rightward. 1.0 = no extension, 1.5 = 50% extension rightward. |
| context_from_mask_extend_factor | FLOAT | 1.201–100 | Expand the context area around the mask by this factor. 1.2 = 20% expansion in all directions. Larger values include more surrounding context for better inpainting. |
| output_resize_to_target_size | BOOLEAN | true | Resize the output to specific dimensions. When disabled, output size depends on mask area and extend factor. |
| output_target_width | INT | 51264–16384 | Target width for output image when resize to target size is enabled. Should match your inpainting model's preferred resolution. |
| output_target_height | INT | 51264–16384 | Target height for output image when resize to target size is enabled. Should match your inpainting model's preferred resolution. |
| output_padding | COMBO | 32 | Padding to ensure output dimensions are multiples of this value. Important for models that require specific dimension alignment (e.g., 8 for VAE, 32 for some diffusion models). |
| keep_window_size | BOOLEAN | false | Maintain consistent crop window size across all images in batch. Essential for video processing to avoid flickering. Uses maximum dimensions found and interpolates missing coordinates. |
| maskopt | MASK | Mask defining areas to be inpainted. White areas will be inpainted, black areas will be preserved. If not provided, the entire image will be processed. | |
| optional_context_maskopt | MASK | Additional mask defining extra context areas to include in the crop. Useful for ensuring important surrounding details are preserved during inpainting. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| stitcher | STITCHER | Stitcher data containing all information needed to reconstruct the original image after inpainting. Pass this to InpaintStitchImproved. |
| cropped_image | IMAGE | Cropped and processed image ready for inpainting. Contains the masked area plus surrounding context. |
| cropped_mask | MASK | Processed mask corresponding to the cropped image. Shows which areas need to be inpainted. |