https://github.com/rrivera/identicon
Open source avatar generator inspired by GitHub avatars.
https://github.com/rrivera/identicon
avatar golang identity-icon image
Last synced: 8 days ago
JSON representation
Open source avatar generator inspired by GitHub avatars.
- Host: GitHub
- URL: https://github.com/rrivera/identicon
- Owner: rrivera
- License: mit
- Created: 2018-06-25T20:14:17.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-01-16T19:54:54.000Z (over 1 year ago)
- Last Synced: 2024-07-31T09:18:30.105Z (12 months ago)
- Topics: avatar, golang, identity-icon, image
- Language: Go
- Homepage:
- Size: 34.2 KB
- Stars: 88
- Watchers: 4
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# IdentIcon

[](https://goreportcard.com/report/github.com/rrivera/identicon) [](http://godoc.org/github.com/rrivera/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
```bash
$ go get github.com/rrivera/identicon
```## Usage
```go
import (
"os""github.com/rrivera/identicon"
)// New Generator: Rehuse
ig, err := identicon.New(
"github", // Namespace
5, // Number of blocks (Size)
3, // Density
)if err != nil {
panic(err) // Invalid Size or Density
}username := "rrivera" // Text - decides the resulting figure
ii, err := ig.Draw(username) // Generate an IdentIconif err != nil {
panic(err) // Text is empty
}// File writer
img, _ := os.Create("icon.png")
defer img.Close()
// Takes the size in pixels and any io.Writer
ii.Png(300, img) // 300px * 300px```
## Examples
### 5x5
|rrivera | johndoe | abc123 | modulo |
:------------------------------------------------:|:---------------------------------------------:|:-------------------------------------------:|:--------------------------------------------|
 |  |  |  |
 |  |  |  |
 |  |  |  |### 7x7
|rrivera | johndoe | abc123 | modulo |
:------------------------------------------------:|:---------------------------------------------:|:-------------------------------------------:|:---------------------------------------------|
 |  |  |  |
 |  |  |  |
 |  |  |  |
### 10x10
|rrivera | johndoe | abc123 | modulo |
:--------------------------------------------------:|:-----------------------------------------------:|:---------------------------------------------:|:----------------------------------------------|
 |  |  |  |
 |  |  |  |
 |  |  |  |[View examples](./examples)
## Documentation
## Changelog
## Contribution
## License
MITCopyright (c) 2018-present, Ruben Rivera