Socket
Book a DemoInstallSign in
Socket

autocrop-js

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autocrop-js

Node.js utility that crops the transparent background of an image

0.2.0
latest
Source
npmnpm
Version published
Weekly downloads
57
-45.19%
Maintainers
1
Weekly downloads
 
Created
Source

autocrop-js

Illustration of how autocrop-js works (Used image from https://pixabay.com/illustrations/ai-generated-generative-ai-fantasy-7700016/)

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.

License

MIT

Keywords

image

FAQs

Package last updated on 13 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.