Nodes/comfyui-timesaver/TS Crop To Mask
ComfyUI Node

TS Crop To Mask

Crop a batch around its mask with padding, a resolution clamp, fixed aspect and inter-frame smoothing for video.

By AlexYez·Created 2 years ago·Updated 3 days ago· 11
TS Crop To Mask
  • images
  • mask
  • cropped_images
  • cropped_masks
  • crop_data
  • width
  • height
padding64
divide_by32
max_resolution720
fixed_mask_frame_index0
interpolation_window_size0
force_gputrue
fixed_crop_sizefalse
fixed_width1024
fixed_height1024
CategoryTS/Image/Tiles

Inputs (11)

NameTypeDefaultDescription
imagesIMAGEBatch of images to crop around the mask region.
maskMASKMask that defines the region to crop. The bounding box of its non-zero area sets the crop.
paddingINT640–320Extra pixels added around the mask bounding box before cropping.
divide_byINT321–64Rounds the crop dimensions up to a multiple of this value (e.g. 32 for VAE-friendly sizes).
max_resolutionINT720320–2048Caps the shorter side of the crop. Larger crops are downscaled to this limit.
fixed_mask_frame_indexINT00–99991-based frame whose mask defines one fixed crop for the whole batch. 0 = per-frame crop.
interpolation_window_sizeINT00–100Smooths crop motion across frames by averaging over this many neighbouring frames. 0 = off.
force_gpuBOOLEANtrueRun the crop on GPU when CUDA is available; otherwise falls back to CPU.
fixed_crop_sizeBOOLEANfalseForce every crop to the fixed_width x fixed_height aspect ratio instead of following the mask.
fixed_widthINT102464–4096Target crop width when fixed_crop_size is enabled.
fixed_heightINT102464–4096Target crop height when fixed_crop_size is enabled.

Outputs (5)

NameTypeDescription
cropped_imagesIMAGE
cropped_masksMASK
crop_dataCROP_DATACrop geometry passed to TS Restore From Crop to paste the result back.
widthINTWidth of the cropped output.
heightINTHeight of the cropped output.