vikin/laricon

Generate awesome and unique identicons with beautiful colors

v1.0 2017-04-06 15:11 UTC

This package is auto-updated.

Last update: 2024-04-20 15:28:35 UTC


README

Laricon is a library which generate an identicon image based on a string.

Here is some examples of awesome results!

Identicon example #1   Identicon example #2   Identicon example #3   Identicon example #4   Identicon example #5

Installation

composer require vikin/laricon

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

Add in the config/app.php file

'providers' => [
    ....
    Vikin\Laricon\Providers\LariconServiceProvider::class
],

'aliases' => [
    ....
    'Laricon' => Vikin\Laricon\Facades\Laricon::class
]

Then you can generate and display an identicon image

Laricon::displayImage('vikin');

or generate and get the image data

Laricon::getImageData('vikin');

or generate and get the base 64 image uri ready for integrate into an HTML img tag.

Laricon::getImageDataUri('vikin');
<img src="{{ Laricon::getImageDataUri('vikin') }}" alt="Vikin 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.

Laricon::displayImage('vikin', 512);

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

Laricon::displayImage('vikin', 64, 'A87EDF');

or an array with red, green, blue value

Laricon::displayImage('foo', 64, [200, 100, 150]);

That's it!

License

Identicon is released under the MIT License. See the bundled LICENSE file for details.

From the yzalis/Identicon