Home

Awesome

ngx_http_avatars_gen_module

Say Thanks!

Nginx module to generate gmail-like avatars based on user initials.

Dependencies

Module requires libcairo:

sudo apt-get install libcairo2 libcairo2-dev

Installation

To install module you should compile nginx with it:

cd nginx-1.11.3/
./configure --add-module=/path/to/module/avatars_gen
make && sudo make install

Configuration

Module could be enabled on location context:

http {
    server {
        listen       80;
        server_name  localhost;

        # Default params
        location /avatar {
            avatars_gen;
        }

        # Black & white avatar
        location /bw-avatar {
            avatars_gen;
            avatars_gen_bg_color FFFFFF;
            avatars_gen_contour_color 000000;
            avatars_gen_font_color 000000;
            avatars_gen_font_face serif;
        }

        # Custom size and without contour
        location /big-contourless {
            avatars_gen;
            avatars_gen_size 400;
            avatars_gen_show_contour off;
        }

        # Customized font
        location /font {
            avatars_gen;
            avatars_gen_size 300;
            avatars_gen_font_size 100;
            avatars_gen_font_face "Liberation Sans Narrow";
            avatars_gen_font_bold on;
        }

        # Square form
        location /square {
            avatars_gen;
            avatars_gen_square on;
            avatars_gen_bg_color 72A3F1;
            avatars_gen_contour_color E9AD00;
            avatars_gen_font_color 9BFAB5;
            avatars_gen_size 100;
            avatars_gen_font_face "Liberation Sans";
            avatars_gen_show_contour off;
        }
    }
}

Directives:

You could change avatar colors with GET args (i.e. ?bg_color=FFFFFF&font_color=000000):

Usage

You can make request to http://localhost/avatar/GH and it will generate 100x100 png image on-the-go:

Default:

default

Black & white:

black and white

Custom size and without contour:

big-contourless

Customized font:

customized font

Square form:

square

Module currently supports only 1 and 2 symbols initials.

TODO

License

The MIT License (MIT)

Copyright (c) 2016 Yuri Shikanov