profile-pic

1.2.0 • Public • Published

Profile Picture

Build Status

Create cover and profile pictures with face centered and uniform expected sizes.

It gets an input image and outputs two images: a cover image centered with specified size, and a profile picture with square ratio centered in bigest detected human face.

Install

npm install profile-pic

Usage

var profilePic = require('profile-pic');
var images = [
    /* Landscape Ratio */
    {
        width: 400,
        height: 240,
        filename: '/tmp/landscape.jpg'
    },
    /* Portrait Ratio */
    {
        width: 240,
        height: 400,
        filename: '/tmp/standing.jpg'
    },
    /* detected face avatar with square ratio */
    {
        avatar: true,
        width: 128,
        height: 128,
        filename: '/tmp/profile.jpg'
    }
];
 
profilePic('./test-image.jpeg', images)
    .then(function (result) {
        /*
        [ { width: 400, height: 240, filename: '/tmp/landscape.jpg' },
          { width: 240, height: 400, filename: '/tmp/standing.jpg' },
          { avatar: true,
            width: 128,
            height: 128,
            filename: '/tmp/profile.jpg',
            faces: 5 } ]
        */
    })
    .catch(function (err) {
        // Something bad happened ...
    });

This example will result in 3 images out of this input:

INPUT:

input

OUTPUT:

  • Two centered and resized to expected size:
400x240

landscape.jpg (400x240)

200x120

standing.jpg (400x240)

  • And one avatar image with biggest detected face:
128x128

profile.jpg (128x128)

Package Sidebar

Install

npm i profile-pic

Weekly Downloads

1

Version

1.2.0

License

MIT

Last publish

Collaborators

  • xenomuta