Skip to content

ClydeDz/robohash-avatars-npm

Repository files navigation

Robohash Avatars

Generate robot-based avatar images based on any text.

Build status Azure DevOps tests (branch) Azure DevOps coverage Quality Gate Status Maintainability Rating MIT License npm

Usage

After installing, simply import Robohash Avatars in your file.

const robohashAvatars = require("robohash-avatars");

Consume the generateAvatar() API to get an avatar URL that you can use directly as an image. Supply the settings object to this method to generate the avatar image URL accordingly. Username is required. For the remainder, you can supply them based on your requirement. All settings are pretty self-explanatory.

var avatarURL = robohashAvatars.generateAvatar({   
            username: "tonystark", 
            background: robohashAvatars.BackgroundSets.RandomBackground1,
            characters: robohashAvatars.CharacterSets.Kittens,
            height: 400,
            width: 400
        }); 

Options

CharacterSets supports Robots, Monsters, DisembodiedHeads and Kittens. BackgroundSets supports RandomBackground1 and RandomBackground2

Examples

Clicking on the images below opens the image in a browser window.

Sample image 1 Sample image 2 Sample image 3

Release notes

Release notes can be found here.

Credits

RoboHash.org is developed by Colin Davis / RoboHash GitHub.
This npm package is developed by Clyde D'Souza.