npm.io
1.1.1 • Published 3 years ago

detect-edges

Licence
MIT
Version
1.1.1
Deps
0
Size
6 kB
Vulns
0
Weekly
0
Stars
5

detect-edges

Package version Package size

Smartly detect edges of an image.

Installation

npm install detect-edges

Usage

import detect from "detect-edges";

// Browser
const canvas = document.createElement("canvas");

// Node
import Canvas from "canvas";
const canvas = Canvas.createCanvas(800, 600);

const context = canvas.getContext("2d");
// Edit the canvas' context
// ...

const { left, top, right, bottom } = detect(canvas);

Documentation

detect(canvas, [options])
Name Type Default Comment
canvas HTMLCanvasElement required Tainted canvas element
options Options see below
options
Name Type Default Comment
tolerance Number 0 Level of tolerance for the transparency between 0 and 1 (0 mean no tolerance, 1 mean everything is treated as transparent)
  • If you want to crop an image in Node.js, use crop-node
  • If you want to crop an image using your terminal, use crop-node-cli
  • If you want to crop an image in the browser, use crop-browser

License

MIT

Keywords