facereplace
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

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' // or 'https://acme.com/facePic.jpeg'
const face = FaceReplace(facePic)
  1. 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 them
  2. face.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'
// or
// const FaceReplace = require('facereplace').default

// images on file system
const face = FaceReplace('/tmp/catFace.png')
const imgBuffer = await face.replace('/tmp/picToReplaceFacesWithCatFace.jpeg')
await fs.promises.writeFile('/tmp/replaced.jpeg', imgBuffer)

// images on the internet
const face = FaceReplace()
face.setFacePicture('https://acme.com/face.jpeg') // resets face img, same as passing in first arg to `FaceReplace(firstArg)`
const imgBuffer = await face.replace('https://acme.com/picFullOfFaces.png')

Readme

Keywords

none

Package Sidebar

Install

npm i facereplace

Weekly Downloads

10

Version

0.1.2

License

MIT

Unpacked Size

16.4 MB

Total Files

46

Last publish

Collaborators

  • whatl3y