# detect-edges

> Smartly detect edges of an image

Latest version **1.1.1** (published 2023-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install detect-edges
pnpm add detect-edges
yarn add detect-edges
bun add detect-edges
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2023-09-12 |
| First published | 2020-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | GMartigny |
| Maintainers | gmartigny |
| Keywords | canvas, transparency, opacity, pixels, crop |

## Links

- npm: https://www.npmjs.com/package/detect-edges
- Repository: https://github.com/GMartigny/detect-edges
- Homepage: https://github.com/GMartigny/detect-edges#readme
- Issues: https://github.com/GMartigny/detect-edges/issues
- Funding: https://github.com/GMartigny/detect-edges?sponsor=1
- npm.io page: https://npm.io/package/detect-edges

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2023-09-12
- 1.1.0 — 2021-04-25
- 1.0.1 — 2020-01-23

## README

# detect-edges

[![Package version](https://flat.badgen.net/npm/v/detect-edges)](https://www.npmjs.com/package/detect-edges)
[![Package size](https://flat.badgen.net/bundlephobia/minzip/detect-edges)](https://bundlephobia.com/result?p=detect-edges)

Smartly detect edges of an image.


## Installation

    npm install detect-edges


## Usage

```js
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`](https://github.com/GMartigny/crop-node)
 - If you want to crop an image using your terminal, use [`crop-node-cli`](https://github.com/GMartigny/crop-node-cli)
 - If you want to crop an image in the browser, use [`crop-browser`](https://github.com/GMartigny/crop-browser)


## License

[MIT](license)

---
_Source: https://npm.io/package/detect-edges · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
