Laricon is a library which generate an identicon image based on a string.
Here is some examples of awesome results!
composer require vikin/laricon
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.
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" />
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);
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!
Identicon is released under the MIT License. See the bundled LICENSE file for details.
From the yzalis/Identicon