Wondering what’s next for npm?Check out our public roadmap! »

    better-default-avatar

    0.0.2 • Public • Published

    Named Avatar Generator

    Generate default avatars based on user's name without a sweat

    How to use ❓

    1. Install the library
    npm install named-avatar-generator --save
    1. Start creating avatars
    const AvatarGenerator = require("named-avatar-generator");
     
    AvatarGenerator.generate({ name: "Ameer Jhan", size: 64 }).then(avatar => {
      AvatarGenerator.writeAvatar(avatar, "./default-avatar.jpg");
    });

    The above code will generate an awesome default avatar as shown below

    Default Avatar

    Available options

    AvatarGenerator.generate(options).then(avatar => {
      ...
    });
    Option Description Default
    name Full name of the user No default value
    size Size of the avatar in pixels 40
    bgColor Background color of the avatar A random beautiful color
    font BM font path Sans with best font size

    Utility Functions

    Write avatar

    This can be used to write the image to the filesystem

    AvatarGenerator.writeAvatar(avatar, path)
      .then(() => {
        console.log(`Image written to ${path}`);
      })
      .catch(err => {
        console.log(err);
      });

    Get image as Data URI

    This can be used to get the image as data URI

    AvatarGenerator.getBase64(avatar, mime)
      .then(dataURI => {
        console.log(dataURI);
      })
      .catch(err => {
        console.log(err);
      });

    Get image as buffer

    This can be used to get the image as buffer

    AvatarGenerator.getBuffer(avatar, mime)
      .then(buffer => {
        console.log(buffer);
      })
      .catch(err => {
        console.log(err);
      });

    Available MIME

    The supported MIME are

    • jpeg
    • png
    • bmp

    License

    MIT © Ameer Jhan

    Install

    npm i better-default-avatar

    DownloadsWeekly Downloads

    1

    Version

    0.0.2

    License

    MIT

    Unpacked Size

    12.1 kB

    Total Files

    8

    Last publish

    Collaborators

    • avatar