# opencv-autocrop-photo-id

> Npm package to automatically crop a photo suitable for an ID card based on the subjects face.

Latest version **1.0.10** (published 2023-09-01) · GNU license · 0 weekly downloads

## Install

```sh
npm install opencv-autocrop-photo-id
pnpm add opencv-autocrop-photo-id
yarn add opencv-autocrop-photo-id
bun add opencv-autocrop-photo-id
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.10 |
| Published | 2023-09-01 |
| First published | 2023-02-07 |
| Weekly downloads | 0 |
| License | GNU |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 952.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Tim Butterfield |
| Maintainers | timio23 |
| Keywords | image, image processing, face, crop, opencv, npm, unlicense |

## Links

- npm: https://www.npmjs.com/package/opencv-autocrop-photo-id
- Repository: https://github.com/timio23/opencv-autocrop-photo-id
- Homepage: https://github.com/timio23/opencv-autocrop-photo-id#readme
- Issues: https://github.com/timio23/opencv-autocrop-photo-id/issues
- npm.io page: https://npm.io/package/opencv-autocrop-photo-id

## Dependencies (4)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [jsdom](https://npm.io/package/jsdom.md) ^16.4.0
- [canvas](https://npm.io/package/canvas.md) ^2.6.1
- [opencv4js](https://npm.io/package/opencv4js.md) 0.0.1

## 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.0.10 (latest) — 2023-09-01
- 1.0.9 — 2023-09-01
- 1.0.8 — 2023-09-01
- 1.0.7 — 2023-09-01
- 1.0.5 — 2023-07-17
- 1.0.3 — 2023-02-07
- 1.0.2 — 2023-02-07
- 1.0.1 — 2023-02-07
- 1.0.0 — 2023-02-07

## README

# OpenCV AutoCrop Photo ID (Node.js)

<!-- ![CI](https://github.com/arghyadeep-k/opencv-autocrop-photo-id/workflows/CI/badge.svg?branch=master)
![codecov.io](https://codecov.io/github/arghyadeep-k/opencv-autocrop-photo-id/coverage.svg?branch=master)
![npm](https://img.shields.io/npm/v/opencv-autocrop-photo-id)
![npm bundle size](https://img.shields.io/bundlephobia/min/opencv-autocrop-photo-id)
![Libraries.io SourceRank](https://img.shields.io/librariesio/sourcerank/npm/opencv-autocrop-photo-id)
![Depfu](https://img.shields.io/depfu/arghyadeep-k/opencv-autocrop-photo-id)
![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/opencv-autocrop-photo-id)
![npm](https://img.shields.io/npm/dt/opencv-autocrop-photo-id)
![NPM](https://img.shields.io/npm/l/opencv-autocrop-photo-id?color=blue) -->

![npm](https://img.shields.io/npm/v/opencv-autocrop-photo-id)


This package automatically detects faces in a picture and crops them for use as Photo ID. This is based on the opencv-facecrop by arghyadeep.

## Installation

**Install from command line:**

`npm install --save opencv-autocrop-photo-id`



## Basic Usage
```javascript
const facecrop = require('opencv-autocrop-photo-id');

facecrop('./image-file.jpg', './dest/output.jpg', "image/jpeg", 0.95, 0.25);

/* Outputs image with file name output.jpg in 'dest' folder with the face cropped out.

If multiple faces are detected, the files will be automatically renamed to output-1.jpg, output-2.jpg and so on.
*/
```

## Results

![Example 1](https://github.com/timio23/opencv-autocrop-photo-id/blob/main/tests/774909.jpg)
<br><br>
![Example 2](https://github.com/timio23/opencv-autocrop-photo-id/blob/main/tests/774909.jpg)



## API
**facecrop(input_filename, output_filename, type, quality, factor)**

- **input_filename**: Input String containing file name with relative/absolute filepath.

- **output_filename**: (Optional) Requires a string value which will contains the output file name.

- **type**: (Optional) Requires String value which will tell the format of the output image.

- **quality**: (Optional) Requires a float value between 0 to 1 which stands for the quality index of the output file compares to the input file. Set 1 for no reduction in quality.

- **factor**: (Optional) Percentage by which the area of cropping of the face should be increased to add more details.

## Defaults 

 - **input_filename**: Mandatory parameter
 - **output_filename**: "./output.jpg"
 - **type**: 'image/jpeg'
 - **quality**: 0.95
 - **factor**: 0


## License

OpenCV Autocrop Photo ID is published under the Public GNU license. For more information, see the accompanying LICENSE file. 

<br>

---

<br>

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