Autocrop.js
autocrop.js crops transparency area of images
Install / Use
/learn @lqez/Autocrop.jsREADME
autocrop.js
autocrop crops transparency area of the given image.
Demo site: https://lqez.github.io/autocrop.js/
Install
$ npm install autocrop
Usage
<script src='path/to/autocrop.js'></script>
...
<script>
autocrop(<original_image_element>, (target_image_element), (options));
</script>
If target_image_element is omitted, it will replace original_image_element with the cropped result.
Parameter
const autoCropDefaultOptions = {
bgColor: '#FFFFFF', // Background color.
alphaTolerance: 20, // Pixels that are transparent than this value are considered transparent.
colorTolerance: 20, // Pixels similar to the background color are considered as the background.
invertTolerance: 0.90, // Invert the image if most of non-transparent pixels are background color.
margin: '2%', // Margin
allowInvert: true, // Allow invert if needed.
marker: 'cropped' // Add a marker attribute to prevent duplicated cropping.
};
Example

License
MIT
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
