2017 © Pedro Peláez
 

library identicon

Create awesome unique avatar.

image

yzalis/identicon

Create awesome unique avatar.

  • Tuesday, August 1, 2017
  • by yzalis
  • Repository
  • 15 Watchers
  • 511 Stars
  • 125,012 Installations
  • PHP
  • 19 Dependents
  • 0 Suggesters
  • 82 Forks
  • 6 Open issues
  • 4 Versions
  • 13 % Grown

The README.md

Identicon generator for PHP

Build Status codecov.io, (*1)

Identicon is a library which generate an identicon image based on a string., (*2)

Here is some examples of awesome results!, (*3)

Identicon example #1   Identicon example #2   Identicon example #3   Identicon example #4   Identicon example #5, (*4)

Installation

The recommended way to install Identicon is through composer., (*5)

Just add the library to your project:, (*6)

``` bash composer require yzalis/identicon, (*7)


## Usage Images are generated in PNG format with transparent background. The string can be an email, an IP address, a username, an ID or something else. ### Generate an identicon Create a new ```Identicon``` object. ``` php $identicon = new \Identicon\Identicon();

Then you can generate and display an identicon image, (*8)

``` php $identicon->displayImage('foo');, (*9)


or generate and get the image data ``` php $imageData = $identicon->getImageData('bar');

or generate and get the base 64 image uri ready for integrate into an HTML img tag., (*10)

``` php $imageDataUri = $identicon->getImageDataUri('bar');, (*11)

``` html
<img src="<?php echo $imageDataUri; ?>" alt="bar Identicon" />

Change the size

By default the size will be 64 pixels. If you want to change the image size just add a secondary parameter. 512 x 512px in this example., (*12)

``` php $identicon->displayImage('foo', 512);, (*13)


### Color The color is automatically generated according to the string hash but you can chose to specify a color by adding a third argument. Color can be an hexadecimal with 6 characters ``` php $identicon->displayImage('bar', 64, 'A87EDF');

or an array with red, green, blue value, (*14)

``` php $identicon->displayImage('foo', 64, array(200, 100, 150));, (*15)


That's it! ### Generate an identicon on SVG format The only thing you need to change it this one: ``` php $identicon = new \Identicon\Identicon(new SvgGenerator()); $imageDataUri = $identicon->getImageDataUri('bar'); <img src="<?= $imageDataUri; ?>" alt="bar Identicon" />

Unit Tests

To run unit tests, you'll need and a set of dependencies you can install using Composer:, (*16)

php composer.phar install

Once installed, just launch the following command:, (*17)

./vendor/bin/phpunit

Everything should be ok., (*18)

Credits

Inspired by Github blog post about Identicon., (*19)

License

Identicon is released under the MIT License. See the bundled LICENSE file for details., (*20)

The Versions

01/08 2017

dev-master

9999999-dev http://identicon-php.org

Create awesome unique avatar.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Benjamin Laugueux

image avatar identicon

01/08 2017

1.2.0

1.2.0.0 http://identicon-php.org

Create awesome unique avatar.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Benjamin Laugueux

image avatar identicon

13/07 2014

1.1.0

1.1.0.0 http://identicon-php.org

Create awesome unique avatar.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Benjamin Laugueux

image avatar identicon

16/08 2013

1.0.0

1.0.0.0 http://identicon-php.org

Create awesome unique avatar.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Benjamin Laugueux

image avatar identicon