Smartly detect edges of an image.
npm install detect-edges
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);
Name | Type | Default | Comment |
---|---|---|---|
canvas | HTMLCanvasElement |
required | Tainted canvas element |
options | Options |
see below |
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