Skip to content

GMartigny/crop-browser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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])

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

License

MIT