<commit_before>#initials-avatar

[![Build Status](https://travis-ci.org/holys/initials-avatar.svg?branch=master)](https://travis-ci.org/holys/initials-avatar)
[![Coverage Status](https://coveralls.io/repos/holys/initials-avatar/badge.svg?branch=master&service=github)](https://coveralls.io/github/holys/initials-avatar?branch=master)
[![GoDoc](https://godoc.org/github.com/holys/initials-avatar/avatar?status.svg)](https://godoc.org/github.com/holys/initials-avatar/avatar)


Generate an avatar image from a user's initials. Image background color depends on  name hashes(consistent hashing).


## Installation

*VERSION REQUIRED* **GO 1.3 or greater**

```
$ go get github.com/holys/initials-avatar/...
```


## Usage
### Lib Example 

```
import  "github.com/holys/initials-avatar"

a := avatar.New("/path/to/fontfile")
b, _ := a.DrawToBytes("David", 128)
// now `b` is image data which you can write to file or http stream.
```


### HTTP Example
```
// run the http server. The port is :3000 by default. Assumes $GOBIN is in your $PATH.
$ avatar

// try it on your browser
// http://1172.16.31.10:3000/hello 

// to view avaliable options
$ avatar --help

```

![](./resource/images/hello.png)

```
// Chinese example
http://127.0.0.1:3000/%E5%AD%94
```

![](./resource/images/kong.png)

## HTTP Benchmark
<commit_msg>update doc, fix command<commit_after>#initials-avatar

[![Build Status](https://travis-ci.org/holys/initials-avatar.svg?branch=master)](https://travis-ci.org/holys/initials-avatar)
[![Coverage Status](https://coveralls.io/repos/holys/initials-avatar/badge.svg?branch=master&service=github)](https://coveralls.io/github/holys/initials-avatar?branch=master)
[![GoDoc](https://godoc.org/github.com/holys/initials-avatar/avatar?status.svg)](https://godoc.org/github.com/holys/initials-avatar/avatar)


Generate an avatar image from a user's initials. Image background color depends on  name hashes(consistent hashing).


## Installation

*VERSION REQUIRED* **GO 1.3 or greater**

```
$ go get github.com/holys/initials-avatar/...
```


## Usage
### Lib Example 

```
import  "github.com/holys/initials-avatar"

a := avatar.New("/path/to/fontfile")
b, _ := a.DrawToBytes("David", 128)
// now `b` is image data which you can write to file or http stream.
```


### HTTP Example
```
// run the http server. The port is :3000 by default. Assumes $GOBIN is in your $PATH.
$ avatar server

// try it on your browser
// http://127.0.0.1:3000/hello 

// to view avaliable options
$ avatar --help

```

![](./resource/images/hello.png)

```
// Chinese example
http://127.0.0.1:3000/%E5%AD%94
```

![](./resource/images/kong.png)

## HTTP Benchmark

{'fraction_non_alphanumeric': 0.1832894241625894, 'fraction_numerical': 0.02559277380504328, 'mean_word_length': 4.181286549707602, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '434949', 'n_tokens_mistral': 1044, 'n_tokens_neox': 940, 'n_words': 192}