A simple, fast autocrop library which automagically crops the image. The cropping related functions are based on autocrop.js. This library offloads image processing work from mainthread to workers using workerpool.
npm install autocrop-workerautocrop-worker
===========
[![npm][npm]][npm-url]
[![license][license]][license-url]
A simple, fast autocrop library which automagically crops the image. The cropping related functions are based on autocrop.js
Demo site:
Install
-------
``bash`
$ npm install autocrop-worker
Usage
-----
`javascript`
import autocrop from 'autocrop-worker'
autocrop(
javascript
// workerpool need to be loaded before autocrop-worker.min.js
...
`If
target_image_element is set null, it will replace original_image_element with the cropped result.Parameter
---------
`javascript
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.
version: boolean|string /* Defaults to current timestamp. Used for avoiding crossorigin taint issues due to previous cache.
Set it to false for dataURL and blobs */
};
``Example
-------
!Example image of autocrop-worker.js
Used By
-------
License
-------
MIT
[npm]: https://img.shields.io/npm/v/autocrop-worker.svg
[npm-url]: https://npmjs.com/package/autocrop-worker
[license]: https://img.shields.io/npm/l/autocrop-worker
[license-url]: https://github.com/JohnPremKumar/autocrop-worker/blob/main/LICENCE