SkillAgentSearch skills...

Autocrop.js

autocrop.js crops transparency area of images

Install / Use

/learn @lqez/Autocrop.js
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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

Example image of autocrop.js

License

MIT

Related Skills

View on GitHub
GitHub Stars15
CategoryDevelopment
Updated1y ago
Forks1

Languages

JavaScript

Security Score

60/100

Audited on Feb 23, 2025

No findings