Show HN: Default Avatar Generator

github.com

2 points by pas256 2 days ago

After your team has signed up for a new SaaS or service, I find it bland when everyone has the same generic, grey avatar. I'm a visual person and find it helpful to distinguish users by colors in their avatars, but many people never change from the default avatar. So I thought to myself, why not generate interesting avatars for users when they sign up.

The result is this little gem. It randomly chooses from a set of backgrounds, colors and head shapes, and put a letter on the generated avatar. This should be enough combinations so the change of users getting the same avatar generated is next to zero. It can produce SVGs or JPEGs, depending on your use case. More styles can be added somewhat easily.

I'm already using it for https://magicell.com/ and haven't seen any duplicates.

I am very open to feedback on this so please let me know what you think.

gus_massa 2 days ago

How is the background chosen? Can it be generated from a hash like Gravatar?

Also, I get an error when I go to magicell.

  • pas256 2 days ago

    Each avatar has 3 layers: background, foreground (head), and text (single letter).

    The background code chooses from one of the background SVGs (gradients in different directions with color placeholders) and then selects colors to put into the SVG. The whole things is meant to be easy to extend to fit your needs.

    My understanding with Gravatar is that your email is hashed in order to select an avatar you have already uploaded, but is not used in customizing the avatar. Is that right?

    What did you have in mind?

    Also, what error do you get on Magicell? There are some geo-restrictions in place, so I am curious what you saw. Thanks!

    • gus_massa a day ago

      IIRC Gravatar has an option to generate a default image if you didn't upload your own avatar. Imagine that the the has was 89A3 then the image was a 2x2 square with colors 8, 9, A and 3; using some number2rgb function so it was green, yellow, white and red or something like that. I'm making up the details! And they used other shapes and more than 4 parts, but I hope my description is good enough. I found some nice discussion with the details of the real implementation in https://meta.stackexchange.com/questions/17443/how-is-the-de...

      A few years ago it was popular to make Gravatar "clones". One generate weird robots instead of geometric shapes. Another generated aliens. ...

      In Magicell I get "403 Forbidden", I'm in Argentina.