Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/freearhey/autocrop-js
Node.js utility that crops the transparent background of an image.
https://github.com/freearhey/autocrop-js
Last synced: about 1 month ago
JSON representation
Node.js utility that crops the transparent background of an image.
- Host: GitHub
- URL: https://github.com/freearhey/autocrop-js
- Owner: freearhey
- Created: 2022-12-21T21:12:10.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-01-13T09:43:51.000Z (almost 2 years ago)
- Last Synced: 2024-10-08T01:37:04.651Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 1.11 MB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# autocrop-js
![Illustration of how autocrop-js works (Used image from https://pixabay.com/illustrations/ai-generated-generative-ai-fantasy-7700016/)](illustration.png)
Node.js utility that crops the transparent background of an image.
## Installation
```bash
npm install autocrop-js
```## Usage
```js
import autocrop from 'autocrop-js'const dataURL = 'data:image/png;base64,...'
autocrop(dataURL, {
alphaThreshold: 10 // the lines and columns will be removed if the alpha channel is below the specified value (0-255). Default: 0
}).then(result => {
console.log(result)
})
```Output:
```js
{
bbox: { // bounding box of the cut image fragment
height: 188,
width: 232,
x: 26,
y: 0
},
dataURL: 'data:image/png;base64,iVB...' // Data URL of the cut image fragment
}
```## Testing
```bash
npm test
```## Linting
```bash
npm run lint
```## Contribution
If you find a bug or want to contribute to the code or documentation, you can help by submitting an [issue](https://github.com/freearhey/autocrop-js/issues) or a [pull request](https://github.com/freearhey/autocrop-js/pulls).
## License
[MIT](http://opensource.org/licenses/MIT)