1.1.0 • Published 1 year ago

crop-browser v1.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
1 year ago

crop-browser

Package version Package size

Crop all transparent pixel around an image's edges.

Installation

NPM

You'll then need to bundle your code with a bundler.

npm install crop-browser

CDN

You don't need installation, just import from a CDN.

Usage

// With NPM
import crop from "crop-browser";
// Or simply use directly
import crop from "https://www.unpkg.com/crop-browser";

// Run the async function and display the result
(async () => {
    const cropped = await crop("path/to/image.png");
    // Display the file (for example)
    document.body.appendChild(cropped);
})();

Documentation

crop(input, [options])

NameTypeDefaultComment
inputString\|anyrequiredPath to the image to process or any type supported by Canvas.prototype.drawImage
optionsOptions(see below)Some options

options

NameTypeDefaultComment
outputFormatString"png"Format of the output image ("png" or "jpeg")

In addition, all options of detect-edges are supported.

Related

License

MIT