Skip to content

zxc7563598/avatar-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Avatar Service

A random avatar generation service written in Go, supporting multiple avatar styles (Identicon, Pixel).
Ideal for personal projects, application registration avatars, fun tools, etc., making every default avatar unique.

This project has been parsed by Zread. If you need a quick overview of the project, you can click here to view it:Understand this project


Features

  • Multiple Avatar Styles

    • Identicon: Symmetrical grid style (GitHub-like)
    • Pixel: Pixel block style
  • Reproducible
    The same seed always generates the same avatar

  • Lightweight
    No external dependencies, can be compiled into a single binary

  • Server Deployable
    HTTP API returns PNG images, easy to integrate with web services

  • High Performance
    Go’s high-performance rendering + PNG output + caching reduces repeated generation


Project Structure

/avatar-service
├── main.go                 # Main file
├── internal/
│   ├── generator/
│   │   ├── identicon.go    # Identicon style generation logic
│   │   ├── pixel.go        # Pixel style generation logic
│   ├── cache/              # Simple in-memory cache logic
│   └── utils/              # Hash utility functions
└── README.md

Installation & Running

  1. Clone the repository:
git clone https://github.com/zxc7563598/avatar-service.git
cd avatar-service
  1. Install dependencies:
go mod tidy
  1. Run directly:
go run main.go --port 8080

The service will start at http://localhost:8080

  1. Build and run as a binary:
go build -o app
./app --port=8080

API Usage

Get an Avatar

GET /avatar?seed=<seed>&style=<style>
  • seed: String used to generate the avatar (same seed always produces the same avatar)

  • style: Avatar style, optional values:

    • identicon -- Symmetrical grid style (GitHub-like)
    • pixel -- Pixel block style
  • Example:

http://localhost:8080/avatar?seed=hejunjie&size=128&style=pixel

Future Plans

I plan to add more generation types in the future to make avatars more diverse and fun:

  • Simple Face Combinations: Different hair, eyes, accessories (glasses, etc.)
  • Color Randomization: Random colors for each element
  • More Styles: Beyond grids and pixel blocks, generate more personalized and cute default avatars

These enhancements aim to make every avatar more fun and unique.


Contributing & Feedback

If you find this project interesting, feel free to:

  • ⭐ Star the project
  • 🐛 Submit issues or suggestions
  • 📥 Fork and try using it in your own projects

Any feedback motivates me to improve this project, and contributions of new avatar styles and features are always welcome!

About

一个基于 Go 实现的轻量级随机头像生成服务。用户可通过访问接口,使用指定的 seed 自动生成唯一的头像图像 | A lightweight random avatar generation service based on Go implementation. Users can automatically generate unique avatar images using specified seeds through the access interface

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages