Files
xiaden 315666c7b6 refactor: restructure into subpackages, add _shared layer, remove AI slop
- Split flat node modules into categorized subpackages (tagging, detect,
  edge, pose, segment, restore, compare, judge, transform, utility)
- Extract shared internals into _shared/ (bases, tensor, formatting)
- Centralize node registration via register_nodes() helper
- Clean up: remove dead is_scored return, unnecessary hasattr guard,
  inline imports
2026-07-05 08:59:48 +00:00

30 lines
1.4 KiB
Python

"""Auto-crop image to visible content via transparency thresholding."""
from comfy_api.latest import io
from .._shared.bases import _ImageToImage
class ImgUtilsSqueeze(_ImageToImage):
"""Auto-crop image to visible content using transparency threshold."""
@classmethod
def define_schema(cls) -> io.Schema:
return io.Schema(
node_id="ImgUtilsSqueeze", display_name="Imgutils Squeeze",
category="imgutils/transform",
description="Auto-crop image to visible content using transparency threshold.",
search_aliases=["squeeze", "crop", "trim", "auto-crop", "transparency"],
inputs=[
io.Image.Input("image", tooltip="Input image with transparent regions."),
io.Float.Input("threshold", default=0.7, min=0.0, max=1.0, step=0.05, tooltip="Transparency threshold for crop."),
io.Int.Input("median_filter", default=5, min=0, max=15, step=1, tooltip="Median filter size for mask smoothing."),
],
outputs=[io.Image.Output(display_name="image")],
)
@classmethod
def execute(cls, image, threshold, median_filter) -> io.NodeOutput:
from imgutils.operate import squeeze_with_transparency
mf = median_filter if median_filter > 0 else None
return cls._run(image, squeeze_with_transparency, threshold=threshold, median_filter=mf)