Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

avatars

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

avatars

Pixel avatar generator

  • 0.9.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

avatars

Pixel avatar (npm-like) generator.

This module using strings as seed for generator. There are some examples:

Some random string (with 3 colors):

alt example

admin (with 2 colors):

alt example

username (with 2 colors and bigger cells):

alt example

Install

npm install --save avatars

Usage

Basic promise usage:

var avatars = require('avatars');
avatars()
    .then(image => {
        image.write("./text.png", (err) => {
            if (err) throw err;
            console.log("Created text.png");
        });
    })
    .catch(e => console.error(e));

Basic callback usage:

var avatars = require('avatars');
avatars(null, function(error, image) {
    if (error) throw error;
    
    image.write("./text.png", (err) => {
        if (err) throw err;
        console.log("Created text.png");
    });
});

First argument of avatars() is parameters object for image generation. Avatars return image object that is created by Jimp module.

Parameters

ParameterDescription
seedSome string that will be used as a seed for randomizer (default: random string)
widthWidth of the output image in px (default: 256)
heightHeight of the output image in px (default: 256)
pwidthWidth of the generated pattern in cells (default: 16)
pheightHeight of the generated pattern in cells (default: 16)
filenameFilename to write the image (default: null)

Example

var avatars = require('avatars');

var params = {
    seed: 'Some Random Name',   // can be username, login, id etc
    width: 500,
    height: 500,
    pwidth: 15,
    pheight: 15,
    filename: './test.png'  // file with this name will be created
};

avatars(params)
    .then(image => {
        console.log("Created text.png");
    })
    .catch(e => console.error(e));

Keywords

FAQs

Package last updated on 13 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc