Autocrop
Automatic energy-based image cropping implementation in Go
Install / Use
/learn @mandykoh/AutocropREADME
autocrop
autocrop is an automatic image cropping/region-of-interest finding implementation in Go.
autocrop uses an energy-based approach to determine regions of visual interest at which to stop cropping. Cropping is alpha channel aware and supports images with translucency.
autocrop currently assumes image data is sRGB encoded.
See the API documentation for more details.
Some examples of cropping decisions made by autocrop can be seen here:
Threshold 0.3

Threshold 0.1

Threshold 0.15

This software is made available under an MIT license.
Example usage
Find the autocropped bounds of an image using BoundsForThreshold:
croppedBounds := autocrop.BoundsForThreshold(img, energyThreshold)
The energyThreshold is a value between 0.0 and 1.0 which determines at what energy level cropping stops, relative to the maximum energy of the image. Higher threshold values result in more aggressive cropping.
The ToThreshold function can be used to conveniently get a cropped image if you don’t need the bounds:
croppedImg := autocrop.ToThreshold(img, energyThreshold)
Command line tool
autocrop also provides a command line tool that can be installed as follows:
$ go install github.com/mandykoh/autocrop/cmd/autocrop
and used to crop images like this:
$ autocrop <input_image> <output_png> [threshold]
The threshold is optional and defaults to 0.1.
Related Skills
node-connect
339.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.8kCommit, push, and open a PR
