Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/pshopper/avatar

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/pshopper/avatar

  • v0.0.0-20181127120533-bd18cf58b988
  • Source
  • Go
  • Socket score

Version published
Created
Source

Avatar: Generate Avatars for the web

Build Status Go Report Card Coverage Status GoDoc

Avatar is a package that allows you to create avatars for pictures and initials.

You can create square avatars, or round avatars.

Picture:

    size := 200

    fileBytes, _ := ioutil.ReadFile("./test_data/super_mascot.jpg")
    newAvatar, _ := NewAvatarFromPic(fileBytes, &PictureOptions{
        Size: size, // default 300
    })

    round, err := newAvatar.Circle()
    roundFile, _ := os.Create("./output/round_super_mascot.png")
    roundFile.Write(round)

    square, err := newAvatar.Square()
    squareFile, _ := os.Create("./output/square_super_mascot.png")
    roundFile.Write(square)

Initials:

    size := 200
    newAvatar, err := NewAvatarFromInitials([]byte("John Smith"), &InitialsOptions{
        FontPath:  "./test_data/Arial.ttf",    // Required
        Size:      size,                       // default 300
        NInitials: 2,                          // default 1 - If 0, the whole text will be printed
        TextColor: color.White,                // Default White
        BgColor:   color.RGBA{0, 0, 255, 255}, // Default color.RGBA{215, 0, 255, 255} (purple)
    })

    square, _ := newAvatar.Square()
    squareFile, _ := os.Create("./output/square_john_smith_initials.png")
    defer squareFile.Close()
    squareFile.Write(square)

    round, _ := newAvatar.Circle()
    roundFile, _ := os.Create("./output/round_john_smith_initials.png")
    defer roundFile.Close()
    roundFile.Write(round)

The input for initials can be any text, and the package identifies the best candidates for the initials.

If you give it an email address, it will try to identify the initials in the string preceding the @.

Not specifying NInitials in options would print the whole text as is.

And the font path is required, so maybe it should not be put in InitialsOptions, we'll see what the community thinks.

What you get:

From our original picture:

Square: Super Mascot

Our outputs

Square: John Smith Round: John Smith Square: Mascot Round: Mascot

FAQs

Package last updated on 27 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc