dev-master
9999999-dev
MIT
The Requires
- php >=5.3.0
- malenki/argile *
by Michel Petit
generator avatar svg identicon picture png
1.0.0
1.0.0.0
MIT
The Requires
- php >=5.3.0
- malenki/argile *
by Michel Petit
generator avatar svg identicon picture png
Wallogit.com
2017 © Pedro Peláez
Generator of random avatars aka identicons, like you can see on Stackoverflow for example!, (*1)
This PHP library create a md5 sum from the string you give., (*2)
Each two character is taken, so, we get a string of 32 ÷ 2 = 16 characters., (*3)
For this 16 hexadecimal characters, we take the first 8 of them to choose basic shapes to use in the picture, the 6 followings are used to create the foreground color, the last but one is used to place basic shapes and the last is used to choose the rotation way of each quarter part., (*4)
You get by default a picture of 128px × 128px. This picture can be SVG or PNG. For PNG, you must have one of this PHP modules: ImageMagick or GD., (*5)
I recommand you the first one. GD is a fallback very poor (no scaling and antialias if you have PHP version prior to 5.5)., (*6)
You can display PNG images or store them. As you want., (*7)
SVG can be used into HTML5 document or as standalone SVG file., (*8)
Using composer it is very simple., (*9)
Just put this into your composer.json file:, (*10)
``` json require: "malenki/aleavatar": "dev-master", (*11)
## Do you have some examples? Yes. The first, very simple, generates a (pseudo)random SVG avatar and save it into `my_avatar.svg` file: ``` php $a = new Malenki\Aleavatar\Aleavatar(); $a->generate()->svg('my_avatar.svg');
Now, this one generates one SVG avatar to display into HTML5 based on the string "My avatar is fun!": ``` php $a = new Malenki\Aleavatar\Aleavatar("My avatar is fun!"); $strSVG = $a->generate()->svgForHtml5();, (*12)
The same but to generate PNG to display on browser : ``` php $a = new Malenki\Aleavatar\Aleavatar("My avatar is fun!"); header('Content-Type: image/png'); echo $a->generate()->png(); exit();
You can change size in pixel too:
php
$a = new Malenki\Aleavatar\Aleavatar();
$a->generate(200)->svg('my_avatar.svg');, (*13)
Note: If you have GD as fallback, and your PHP version is inferior to 5.5, then you have not scaling., (*14)
Enjoy!, (*15)
MIT
generator avatar svg identicon picture png
MIT
generator avatar svg identicon picture png