2.1.0 • Published 4 years ago

crop-node v2.1.0

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

crop-node

Package version Package size

Crop all transparent pixel around an image's edges. (CLI version)

Installation

npm install crop-node

Usage

const crop = require("crop-node");
const { writeFileSync } = require("fs");

// Path to an image file
const path = "path/to/image.png";
const options = {
    outputFormat: "png",
};
// Run the async function and write the result
(async () => {
    const cropped = await crop(path, options);
    // Write the file (for example)
    writeFileSync("cropped.png", cropped);
})();

Documentation

crop(input, [options])

NameTypeDefaultComment
inputString|HTMLCanvasElementrequiredPath to the image to process or a tainted canvas
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