1.0.1 ā€¢ Published 4 years ago

crop-universal v1.0.1

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

crop-universal

Package version Package size

Crop all transparent pixel around an image's edges.

āš ļø This package is environment agnostic. It requires you to provide a Canvas implementation. It'll be more simple for you to use:

Installation

npm install crop-universal

Usage

import crop from "crop-universal";

// You're in charge of providing a couple of function corresponding to your environment
const cropper = crop({createCanvas, loadImage});

const url = "path/to/file.png";
const options = {
    outputFormat: "png",
};
const canvas = cropper(url, options);

Documentation

crop(environment)

NameTypeDefaultComment
environmentObjectrequiredObject holding a createCanvas and a loadImage implementation

This will return a Function that you can use to crop.

crop(environment)(input, [options])

NameTypeDefaultComment
inputString\|anyrequiredPath to the image to process or any type supported by your Canvas.prototype.drawImage environment
optionsOptionsundefinedAllow to forward options to detect-edges

This will return a canvas with the result drawn onto.

License

MIT