项目作者: viest

项目描述 :
Laravel generate awesome and unique identicons with beautiful colors
高级语言: PHP
项目地址: git://github.com/viest/laricon.git
创建时间: 2017-04-06T14:04:47Z
项目社区:https://github.com/viest/laricon

开源协议:

下载


Identicon generator for Laravel

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

  1. 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

  1. 'providers' => [
  2. ....
  3. Vikin\Laricon\Providers\LariconServiceProvider::class
  4. ],
  5. 'aliases' => [
  6. ....
  7. 'Laricon' => Vikin\Laricon\Facades\Laricon::class
  8. ]

Then you can generate and display an identicon image

  1. Laricon::displayImage('vikin');

or generate and get the image data

  1. Laricon::getImageData('vikin');

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

  1. Laricon::getImageDataUri('vikin');
  1. <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.

  1. 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

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

or an array with red, green, blue value

  1. 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