autocrop-js
v0.2.0
Published
Node.js utility that crops the transparent background of an image
Downloads
164
Maintainers
Readme
autocrop-js
Node.js utility that crops the transparent background of an image.
Installation
npm install autocrop-js
Usage
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:
{
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
npm test
Linting
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 or a pull request.