Kevin McIntyre f84b511895 init
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00
2025-06-18 01:00:00 -04:00

Jdenticon-go

Go library for generating highly recognizable identicons.

Sample identicons

Features

go-jdenticon is a Go port of the JavaScript library Jdenticon.

  • Renders identicons as PNG or SVG with no external dependencies
  • Generates consistent, deterministic identicons from any input string
  • Highly customizable color themes and styling options
  • Simple, clean API for easy integration
  • Command-line tool included for standalone usage

Installation

go get github.com/kevin/go-jdenticon

Usage

Basic Usage

package main

import (
    "fmt"
    "github.com/kevin/go-jdenticon/jdenticon"
)

func main() {
    // Generate an identicon
    icon := jdenticon.Generate("user@example.com", 200)
    
    // Get SVG output
    svg := icon.ToSVG()
    fmt.Println(svg)
    
    // Get PNG output
    png := icon.ToPNG()
    // Save or use PNG data...
}

Custom Configuration

config := &jdenticon.Config{
    Hue:        0.3,
    Saturation: 0.7,
    Lightness:  0.5,
    Padding:    0.1,
}

icon := jdenticon.GenerateWithConfig("user@example.com", 200, config)

Command Line Tool

# Generate SVG
go run cmd/jdenticon/main.go -value "user@example.com" -size 200

# Generate PNG file
go run cmd/jdenticon/main.go -value "user@example.com" -format png -output icon.png

API Reference

Functions

  • Generate(value string, size int) *Icon - Generate an identicon with default settings
  • GenerateWithConfig(value string, size int, config *Config) *Icon - Generate with custom configuration
  • DefaultConfig() *Config - Get default configuration settings

Types

Icon

  • ToSVG() string - Render as SVG string
  • ToPNG() []byte - Render as PNG byte data

Config

  • Hue float64 - Color hue (0.0-1.0)
  • Saturation float64 - Color saturation (0.0-1.0)
  • Lightness float64 - Color lightness (0.0-1.0)
  • BackgroundColor string - Background color (hex or empty for transparent)
  • Padding float64 - Padding as percentage of size (0.0-0.5)

License

MIT License - see the original Jdenticon project for details.

Contributing

Contributions are welcome! Please ensure all tests pass and follow Go conventions.

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request
Description
Go Jdenticon library - generates identicon avatars
Readme 12 MiB
Languages
Go 89.4%
Shell 6.5%
JavaScript 2.6%
Makefile 1.5%