profile-pic
v1.2.0
Published
Create cover and profile pictures with face centered and uniform expected sizes.
Downloads
21
Maintainers
Readme
Profile Picture
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:
OUTPUT:
- Two centered and resized to expected size:
landscape.jpg (400x240)
standing.jpg (400x240)
- And one avatar image with biggest detected face:
profile.jpg (128x128)