initials-avatar icon indicating copy to clipboard operation
initials-avatar copied to clipboard

Generate an avatar image from a user's initials, ideal for use as a meaningful gravatar fallback.

Initials Avatar

Generate an avatar image from a user's initials, ideal for use as a meaningful gravatar fallback. For example:

Usage

Basic Usage

Generate a 100x100 avatar for the initials JD:

http://initials.me/jd

Basic avatar

Specifying Size

Generate an 50x50 avatar for the initials JS:

http://initials.me/js?s=50

50x50 avatar

Specifying Colors

Generate an avatar with custom foreground/background colors:

http://initials.me/js?s=50&fg=336699&bg=ffcc00

Colored avatar

Use as a Gravatar Fallback

Show the Gravatar for a particular user, and fallback to showing their initials (JD) if the Gravatar doesn't exist:

http://www.gravatar.com/avatar/00000000000000000000000000000000?d=http%3A%2F%2Finitials.me%2FJD

Dependencies

This app requires ImageMagick and Ghostscript to be installed:

Mac

$ brew install imagemagick ghostscript

Ubuntu

$ sudo apt-get install ruby-dev libmagickwand-dev imagemagick

Installation

bundle install

Starting the Server

Rackup

For running locally, I recommend using the rackup command:

$ rackup

Docker

You can run this in production using Docker as follows:

$ docker pull loopj/initials-avatar
$ docker run -p 80:80 loopj/initials-avatar

Mounting Under a Rails App

If you'd like to run this from inside an existing rails app, you can mount it as follows in config/routes.rb:

match "/initials-avatar" => InitialsAvatar, :anchor => false

You can then access avatars at /initials-avatar/:initials from your rails app.