char-to-avatar
v0.2.0
Published
Convert a character to avatar image in NodeJS
Downloads
5
Readme
char-to-avatar
Convert a character to avatar image in NodeJS.
Dependencies
- Cairo: http://cairographics.org/ (libpng giflib freetype libpixman cairo)
Demo
Installation
npm install char-to-avatar
API
var CharToAvatar = require('char-to-avatar')
new CharToAvatar(character[, options])
character
: {String}, a character to render.options.color
: {String}, character color, default to'#ffffff'
.options.backgroundColor
: {String}, background color, default to'#383838'
.options.shape
: {String},'square'
or'circle'
,avatar shape, default to'square'
.options.size
: {Number}, avatar size, default to100
.
CharToAvatar.prototype.pngStream()
Return a png image stream.
CharToAvatar.prototype.jpegStream([quality])
Return a jpeg stream.
quality
: {Number},0 - 100
, jpeg quality, default is85
.
CharToAvatar.prototype.toBuffer()
Return a thunk function that guarantee a png image buffer.
CharToAvatar.prototype.toDataURL([mime])
Return a thunk function that guarantee a image data string.
mime
: {String}, mime type, default is'image/png'
.