1.0.0 • Published 4 years ago

crop-browser v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

crop-browser

Package version Package size

Crop all transparent pixel around an image's edges.

Installation

npm install crop-browser

Usage

import crop from "crop-browser";

// Path to an image file
const path = "path/to/image.png";
const options = {
    outputFormat: "png",
};
// Run the async function and display the result
(async () => {
    const cropped = await crop(path, options);
    // 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