New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

better-default-avatar

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-default-avatar

Generate avatars with first letter of user's first and last name

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Named Avatar Generator

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

How to use :question:

  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 => {
  ...
});
OptionDescriptionDefault
nameFull name of the userNo default value
sizeSize of the avatar in pixels40
bgColorBackground color of the avatarA random beautiful color
fontBM font pathSans 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

Keywords

FAQs

Package last updated on 01 Apr 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