This package helps you to auto-detect faces in a picture and crop them out.
Install from command line:
npm install --save opencv-facecrop
const facecrop = require('opencv-facecrop');
const faceBuffers = facecrop('./image-file.jpg', './dest/output.jpg', "image/jpeg", 0.95, 1.5);
/*
Outputs array of buffers for each face cropped out.
*/
Original Image:
Image by Free-Photos from PixabayCropped Image:
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) Scaling Factor by which the area of cropping of the face can be increased/decreased to add more details. Must be greater than 0.
- input_filename: Mandatory parameter
- output_filename: "./output.jpg"
- type: 'image/jpeg'
- quality: 0.95
- factor: 1
To view the changelogs, please refer to the Github Releases page of this project.
OpenCv - Face Crop is published under the Unlicense. For more information, see the accompanying LICENSE file.
P.S. - This is a pre-release version. More updates with refinements coming soon.