Skip to content

GMartigny/detect-edges

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

Related

  • 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