MonsterID¶
MonsterID is a method to generate a unique monster image based upon a certain identifier (IP address, email address, whatever). It can be used to automatically provide personal avatar images in blog comments or other community services.
MonsterID was inspired by a post by Don Park and the Combinatoric Critters.
Usage¶
Function-style¶
<?php
// use function is available for PHP >= 5.6, call with full namespace in earlier versions
use function SandFox\MonsterID\build_monster;
$image = build_monster('sandfox@sandfox.me', 150);
// save it to file
file_put_contents('avatar.png', $image);
Object-style¶
<?php
use SandFox\MonsterID\Monster;
$monster = new Monster('sandfox@sandfox.me');
// save it to file
file_put_contents('avatar.png', $monster->build(150));
// or output it to browser
header('Content-type: image/png');
echo $monster->build(150);
From 1.3: added forward compatibility with 2.0
<?php
use SandFox\MonsterID\Monster;
$monster = new Monster('sandfox@sandfox.me', 150);
// save it to file
file_put_contents('avatar.png', $monster->getImage());
// or output it to browser
header('Content-type: image/png');
echo $monster->getImage();
License¶
All graphics were created by Andreas Gohr. The source code and the graphics are provided under the MIT License.
Adaptation as a composer library for modern PHP was performed by Anton “Sand Fox” Smirnov