facereplace
Use face recognition API to replace faces in
pictures with a face of your choice using NodeJS.
Install
npm install --save facereplace
CLI/Quickstart
facereplace contains a CLI utility you can use to replace faces
in pictures without writing your own script/code.
$ npm install -g facereplace
$ facereplace -f /path/to/facePic.jpeg -p /path/to/destinationPicToReplaceFaces.jpeg
Successfully replaced faces and saved your file here: /Users/yourname/facereplace_1577203511111.jpeg
$ facereplace -f https://acme.com/facePic.jpeg -p https://acme.com/destinationPicToReplaceFaces.png
Successfully replaced faces and saved your file here: /Users/yourname/facereplace_1577203511111.png
API
See Usage for more details
const facePic = '/tmp/facePic.jpeg'
const face = FaceReplace(facePic)
face.replace(string)
=> Promise<Buffer>: takes a string of the local file path or public URL of the picture we want to replace faces in, and replaces themface.setFacePicture(string)
=> void: takes a string of the local file path or public URL to replace the picture you want to replace all faces in your target picture(s)
Usage
import fs from 'fs'
import FaceReplace from 'facereplace'
const face = FaceReplace('/tmp/catFace.png')
const imgBuffer = await face.replace('/tmp/picToReplaceFacesWithCatFace.jpeg')
await fs.promises.writeFile('/tmp/replaced.jpeg', imgBuffer)
const face = FaceReplace()
face.setFacePicture('https://acme.com/face.jpeg')
const imgBuffer = await face.replace('https://acme.com/picFullOfFaces.png')