package module
Version: v0.4.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2021 License: MIT Imports: 18 Imported by: 7



License GoDoc Build Coverage Go Report Card

GOvatar image

GOvatar is an avatar generation library written in GO

  1. From release v0.4.0 onward, the minimal supported golang version is 1.16.


$ brew tap o1egl/tap
$ brew install govatar
$ docker pull o1egl/govatar
From source
$ go get -u

Prebuilt binary packages are available for Mac, Linux, and Windows.


$ govatar generate male -o avatar.png                        # Generates random avatar.png for male
$ govatar generate female -o avatar.png                      # Generates random avatar.png for female
$ govatar generate male -u -o avatar.png   # Generates avatar.png for specified username
$ govatar -h                                                 # Display help message
As lib

Generates avatar and save it to filePath

err := govatar.GenerateFile(govatar.MALE, "/path/to/avatar.jpg")
err := govatar.GenerateFileFromUsername(govatar.MALE, "username", "/path/to/avatar.jpg")

Generates an avatar and returns it as an image.Image

img, err := govatar.Generate(govatar.MALE)
img, err := govatar.GenerateForUsername(govatar.MALE, "username")
Adding new skins
  1. Add new skins to the background, male/clothes, female/hair, etc...
  2. Submit pull request :)
Submitting a Pull Request
  1. Fork it.
  2. Create a branch (git checkout -b my_branch)
  3. Commit your changes (git commit -am "Added new awesome avatars")
  4. Push to the branch (git push origin my_branch)
  5. Open a Pull Request
  6. Enjoy a refreshing Diet Coke and wait

GOvatar is released under the MIT license. See LICENSE




This section is empty.


View Source
var ErrUnsupportedGender = errors.New("unsupported gender")


func Generate

func Generate(gender Gender) (image.Image, error)

Generate generates random avatar

func GenerateFile

func GenerateFile(gender Gender, filePath string) error

GenerateFile generates random avatar and save it to specified file. Image format depends on file extension (jpeg, jpg, png, gif). Default is png

func GenerateFileForUsername

func GenerateFileForUsername(gender Gender, username string, filePath string) error

GenerateFileForUsername generates avatar for username and save it to specified file. Image format depends on file extension (jpeg, jpg, png, gif). Default is png

func GenerateForUsername

func GenerateForUsername(gender Gender, username string) (image.Image, error)

GenerateForUsername generates avatar for username


type Gender

type Gender int

Gender represents gender type

const (
	MALE Gender = iota

Male and female constants


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL