node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


avatar-generator Build Status

8bit avatar generator like one below.

Like this one

Inspired by (icons also theirs). Generate same icons for same ids like gravatar, Use email or md5 or any string for generating and get the same avatar.


Where: id - your user id s - sex (male|female) size - avatar size


Getting Started

Install the module with: npm install avatar-generator

var avatar = require('./lib/avatar-generator')({
    //Optional settings. Default settings in 'settings.js' 
    order:'background face clothes head hair eye mouth'.split(' '), //order in which sprites should be combined 
    images:require('path').join(__dirname,'./img'), // path to sprites 
    convert:'convert' //Path to imagemagick convert 
avatar('User ID (email or hash or any string)', 'male|female', 400)

Image file

avatar('User ID', 'male|female', imageWidth)
    .write(filename, function (err) {});

Image buffer

avatar('User ID', 'male|female', imageWidth)
    .toBuffer(function (err,buffer){
    //Do something with buffer. eg buffer.toString('base64');

Image stream

avatar('User ID', 'male|female', imageWidth)

Install with cli command

$ npm install -g avatar-generator
$ avatar-generator --help
$ avatar-generator --version


See example/*.js


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.


Copyright (c) 2014 Alex R
Licensed under the MIT license.