Nodes/comfyUI-TiledWan/TiledWan Inpaint Crop Improved
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.

By Baverne·Created about a year ago·Updated 6 months ago· 8
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)

NameTypeDefaultDescription
imageIMAGEInput image(s) to be processed. Can be a single image or batch of images for video processing.
downscale_algorithmCOMBObilinearAlgorithm used when downscaling images. Bilinear provides good balance of quality and speed.
upscale_algorithmCOMBObicubicAlgorithm used when upscaling images. Bicubic provides better quality for upscaling.
preresizeBOOLEANfalseEnable to resize the original image before processing. Useful for normalizing input sizes.
preresize_modeCOMBOensure minimum resolutionMode for pre-resizing: minimum ensures image is at least the specified size, maximum caps the size, both enforces a range.
preresize_min_widthINT10240–16384Minimum width for pre-resize operation. Image will be upscaled if smaller.
preresize_min_heightINT10240–16384Minimum height for pre-resize operation. Image will be upscaled if smaller.
preresize_max_widthINT163840–16384Maximum width for pre-resize operation. Image will be downscaled if larger.
preresize_max_heightINT163840–16384Maximum height for pre-resize operation. Image will be downscaled if larger.
mask_fill_holesBOOLEANtrueFill holes in the mask using iterative morphological operations. Helps create more complete masked regions.
mask_expand_pixelsINT00–16384Expand the mask by this many pixels before processing. Useful for including more context around masked areas.
mask_invertBOOLEANfalseInvert the mask so that masked areas become unmasked and vice versa.
mask_blend_pixelsINT320–64Create a soft transition zone around mask edges. Higher values create smoother blending during stitching.
mask_hipass_filterFLOAT0.100–1Remove mask values below this threshold. Helps eliminate weak mask areas and noise.
extend_for_outpaintingBOOLEANfalseExtend the image canvas for outpainting. Adds padding around the image for generating content beyond original boundaries.
extend_up_factorFLOAT1.000.01–100Factor to extend image upward. 1.0 = no extension, 1.5 = 50% extension upward.
extend_down_factorFLOAT1.000.01–100Factor to extend image downward. 1.0 = no extension, 1.5 = 50% extension downward.
extend_left_factorFLOAT1.000.01–100Factor to extend image leftward. 1.0 = no extension, 1.5 = 50% extension leftward.
extend_right_factorFLOAT1.000.01–100Factor to extend image rightward. 1.0 = no extension, 1.5 = 50% extension rightward.
context_from_mask_extend_factorFLOAT1.201–100Expand 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_sizeBOOLEANtrueResize the output to specific dimensions. When disabled, output size depends on mask area and extend factor.
output_target_widthINT51264–16384Target width for output image when resize to target size is enabled. Should match your inpainting model's preferred resolution.
output_target_heightINT51264–16384Target height for output image when resize to target size is enabled. Should match your inpainting model's preferred resolution.
output_paddingCOMBO32Padding 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_sizeBOOLEANfalseMaintain consistent crop window size across all images in batch. Essential for video processing to avoid flickering. Uses maximum dimensions found and interpolates missing coordinates.
maskoptMASKMask 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_maskoptMASKAdditional mask defining extra context areas to include in the crop. Useful for ensuring important surrounding details are preserved during inpainting.

Outputs (3)

NameTypeDescription
stitcherSTITCHERStitcher data containing all information needed to reconstruct the original image after inpainting. Pass this to InpaintStitchImproved.
cropped_imageIMAGECropped and processed image ready for inpainting. Contains the masked area plus surrounding context.
cropped_maskMASKProcessed mask corresponding to the cropped image. Shows which areas need to be inpainted.