IdentIcon
IdentIcon is an open source avatar generator inspired by GitHub avatars.
IdentIcon uses a deterministic algorithm that generates an image (using Golang's stdlib image encoders) based on a text (Generally Usernames, Emails or just random strings), by hashing it and iterating over the bytes of the digest to pick whether to draw a point, pick a color or choose where to go next.
IdentIcon's Generator enables the creation of customized figures: (NxN size, points density, custom color palette) as well as multiple exporting formats in case the developers want to generate their own images.
Installation
$ go get github.com/rrivera/identicon
Usage
import (
"os"
"github.com/rrivera/identicon"
)
ig, err := identicon.New(
"github",
5,
3,
)
if err != nil {
panic(err)
}
username := "rrivera"
ii, err := ig.Draw(username)
if err != nil {
panic(err)
}
img, _ := os.Create("icon.png")
defer img.Close()
ii.Png(300, img)
Examples
5x5
rrivera | johndoe | abc123 | modulo |
---|
| | | |
| | | |
| | | |
7x7
rrivera | johndoe | abc123 | modulo |
---|
| | | |
| | | |
| | | |
10x10
rrivera | johndoe | abc123 | modulo |
---|
| | | |
| | | |
| | | |
View examples
Documentation
Changelog
Contribution
License
MIT
Copyright (c) 2018-present, Ruben Rivera