Skip to content

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

License

Notifications You must be signed in to change notification settings

xenomuta/profile-pic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Profile Picture

Build Status

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

It gets an input image and outputs three images: a cover image centered with specified size in landscape and portrait, 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)

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published