https://github.com/issue9/identicon
Go 语言版 identicon 头像产生工具
https://github.com/issue9/identicon
avatar avatar-generator go golang identicon
Last synced: 4 months ago
JSON representation
Go 语言版 identicon 头像产生工具
- Host: GitHub
- URL: https://github.com/issue9/identicon
- Owner: issue9
- License: mit
- Created: 2015-05-19T09:15:25.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2025-09-10T05:47:24.000Z (9 months ago)
- Last Synced: 2025-09-10T09:03:28.758Z (9 months ago)
- Topics: avatar, avatar-generator, go, golang, identicon
- Language: Go
- Homepage: https://pkg.go.dev/github.com/issue9/identicon/v2
- Size: 122 KB
- Stars: 240
- Watchers: 7
- Forks: 35
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- go-awesome - identicon - 根据用户的 IP 、邮箱名等任意数据为用户产生漂亮的随机头像 (开源类库 / 图形处理)
- go-awesome - identicon - Generate nice random avatar for user based on arbitrary data like user's IP, mailbox name etc. (Open source library / Graphics Processing)
README
# identicon
[](https://github.com/issue9/identicon/actions/workflows/go.yml)
[](https://codecov.io/gh/issue9/identicon)
[](https://pkg.go.dev/github.com/issue9/identicon/v2)


根据用户的 IP 、邮箱名等任意数据为用户产生漂亮的随机头像。
提供了两种风格的头像数据,其中 Style2 风格更加的像素风,且性能也更佳。
style1





style2





```go
// 根据用户访问的IP,为其生成一张头像
img, _ := identicon.Make(Style1, 128, color.NRGBA{},color.NRGBA{}, []byte("192.168.1.1"))
fi, _ := os.Create("/tmp/u1.png")
png.Encode(fi, img)
fi.Close()
// 或者
ii, _ := identicon.New(Style2, 128, color.NRGBA{}, color.NRGBA{}, color.NRGBA{}, color.NRGBA{})
img := ii.Make([]byte("192.168.1.1"))
img = ii.Make([]byte("192.168.1.2"))
```
## 安装
```shell
go get github.com/issue9/identicon/v2
```
## 版权
本项目采用 [MIT](https://opensource.org/licenses/MIT) 开源授权许可证,完整的授权说明可在 [LICENSE](LICENSE) 文件中找到。