ComfyUI Node
Smart Mask Crop
Crops a focused local region around a mask, keeping a local mask for mask-based editing models such as GPT Image.
Smart Mask Crop
- image
- mask
- stitcher
- cropped_image
- cropped_mask
- cropped_mask_image
- preview_image
- info
◄context_expand1.15►
◄use_region_guidancetrue►
◄mask_expand_percent0.0►
◄mask_feather_percent0.0►
◄resize_modeupscale_to_target_if_smaller►
◄target_width1024►
◄target_height1024►
◄downscale_algorithmbilinear►
◄upscale_algorithmbicubic►
◄device_modegpu (much faster)►
◄depad_florencetrue►
◄use_region_mask_defaultstrue►
◄edit_size_scale_percent100►
◄region_info—►
◄target_size_moderegion_recommended►
◄target_aspect_ratioregion_info►
Categoryinpaint/masked
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| context_expand | FLOAT | 1.151–4 | Grow the detected mask region before cropping. |
| use_region_guidance | BOOLEAN | true | Use Florence region metadata to override context and target size when available. |
| mask_expand_percent | FLOAT | 0.00–100 | Extra expansion applied to the edit mask after crop. 0 uses region defaults when guidance is enabled. |
| mask_feather_percent | FLOAT | 0.00–100 | Softens the edit mask edges after crop. 0 uses region defaults when guidance is enabled. |
| resize_mode | COMBO | upscale_to_target_if_smaller | 3 options: keep_local_size, upscale_to_target_if_smaller, resize_to_target |
| target_width | INT | 102464–16384 | — |
| target_height | INT | 102464–16384 | — |
| downscale_algorithm | COMBO | bilinear | 6 options: nearest, bilinear, bicubic, lanczos, box, hamming |
| upscale_algorithm | COMBO | bicubic | 6 options: nearest, bilinear, bicubic, lanczos, box, hamming |
| device_mode | COMBO | gpu (much faster) | 2 options: gpu (much faster), cpu (compatible) |
| depad_florence | BOOLEAN | true | Remove Florence2's internal square letterbox padding before resizing the mask. Keep True when the mask comes from Florence2Run (kijai). Disable only if your mask is already at the exact source image resolution. |
| use_region_mask_defaults | BOOLEAN | true | When enabled, 0 mask expand/feather values use Florence region defaults. Disable it when you need a hard mask. |
| edit_size_scale_percent | FLOAT | 10025–200 | Scale the edit output resolution as a percentage of the target. 100 = full region recommended size (e.g. 2752x1536 for glasses). 50 = half size, 150 = 150%%. Preserves aspect ratio. The scaled size flows via info to GPT Image nodes using auto_from_region, so both crop and output stay aligned. |
| region_infoopt | STRING | — | |
| target_size_modeopt | COMBO | region_recommended | region_recommended uses Florence/region defaults; manual_width_height uses target_width/target_height; max_for_aspect_ratio uses the largest valid GPT Image size for target_aspect_ratio. |
| target_aspect_ratioopt | COMBO | region_info | Aspect ratio used when target_size_mode is max_for_aspect_ratio. |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| stitcher | STITCHER | — |
| cropped_image | IMAGE | — |
| cropped_mask | MASK | — |
| cropped_mask_image | IMAGE | — |
| preview_image | IMAGE | — |
| info | STRING | — |