Package Exports
- crop-node
- crop-node/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (crop-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
crop-node
Crop all transparent pixel around an image's edges. (CLI version)
Installation
npm install crop-node
Usage
import crop from "crop-node";
import { writeFileSync } from "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])
Name | Type | Default | Comment |
---|---|---|---|
input | String|any |
required | Path to the image to process or any type supported by Canvas.prototype.drawImage |
options | Options |
(see below) | Some options |
options
Name | Type | Default | Comment |
---|---|---|---|
outputFormat | String |
"png" |
Format of the output image ("png" or "jpeg" ) |
In addition, all options of detect-edges
are supported.
Related
- CLI version
crop-node-cli
- Browser version
crop-browser
- Environment agnostic
crop-universal