Imgutils Squeeze
Auto-crop transparent images to their content
- image
- image
Once you've got a character cut out on a transparent background, the next annoyance is the empty space around it - a character standing in the middle of a 2048×2048 canvas with hundreds of transparent pixels on every side. Imgutils Squeeze fixes that with one click: it looks at the alpha channel, finds the visible content, and crops to it, trimming away the transparent margins. It's part of the xiaden/comfyui-imgutils pack wrapping the deepghs/imgutils library.
Mechanically it's simple and honest: the node examines the transparency (alpha) values across the image, decides what counts as "visible" via a threshold, builds a crop region, optionally smooths the decision with a median filter, and returns the cropped image. Two knobs:
threshold(default 0.7) - the transparency cutoff for what counts as content. Higher = more conservative (pixels need to be quite opaque to count); lower = more aggressive about keeping faint or semi-transparent content in the crop.median_filter(default 5, range 0–15) - a smoothing filter applied to the alpha mask before cropping, so a stray semi-transparent pixel or a feathered edge doesn't stretch the crop box. Set to 0 to disable it. Values above the default just blur the boundary decision further.
The single output is the cropped image. The source code passes median_filter as None when it's 0, which disables smoothing - useful when you have a clean, hard-edged cutout and want the tightest possible box.
Where it fits
It's the natural tail of a cutout pipeline: Imgutils Segment → transparent character → Imgutils Squeeze → tight asset. Also handy for trimming generated images that were created with extra transparent canvas around the subject, or normalizing the aspect ratio of a batch of cutouts before you feed them somewhere that cares about consistent framing (preview grids, dataset folders, sprite sheets).
Install & gotchas
cd ComfyUI/custom_nodes/
git clone https://github.com/xiaden/comfyui-imgutils.git
cd comfyui-imgutils
pip install -r requirements.txt
Restart ComfyUI. Requires ComfyUI 0.25.0+ - the whole pack is built on the V3 node API. No model download for this one (it's pure pixel math on the alpha channel), so it works offline and instantly, unlike the model-driven nodes in the pack. The one thing that trips people: the image must actually have an alpha channel that's meaningful. If you feed it a normal opaque image, everything counts as content and nothing gets cropped - it silently returns the input. Run Segment (or any transparent-RGBA source) into it, and it does what it says.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image with transparent regions. | |
| threshold | FLOAT | 0.700–1 | Transparency threshold for crop. |
| median_filter | INT | 50–15 | Median filter size for mask smoothing. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |