Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnsupportChar is returned when the character is not supported ErrUnsupportChar = errors.New("unsupported character") // ErrUnsupportedEncoding is returned when the given image encoding is not supported ErrUnsupportedEncoding = errors.New("avatar: Unsuppored encoding") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Maximum number of items the cache can contain (unlimited by default). MaxItems int // Maximum byte capacity of cache (unlimited by default). MaxBytes int64 // TrueType Font file path FontFile string // TrueType Font size FontSize float64 }
Config is the configuration object for caching avatar images. This is used in the caching algorithm implemented by https://github.com/dchest/lru
type InitialsAvatar ¶
type InitialsAvatar struct {
// contains filtered or unexported fields
}
InitialsAvatar represents an initials avatar.
func NewWithConfig ¶
func NewWithConfig(cfg Config) *InitialsAvatar
NewWithConfig provides config for LRU Cache.
func (*InitialsAvatar) DrawToBytes ¶
DrawToBytes draws an image base on the name and size. Only initials of name will be draw. The size is the side length of the square image. Image is encoded to bytes.
You can optionaly specify the encoding of the file. the supported values are png and jpeg for png images and jpeg images respectively. if no encoding is specified then png is used.
Click to show internal directories.
Click to hide internal directories.