MonsterID

Packagist GitHub Gitlab Bitbucket

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.

Monster Example

MonsterID was inspired by a post by Don Park and the Combinatoric Critters.

Installation

Install it with Composer

composer require 'sandfoxme/monsterid:^1.2'

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('[email protected]', 150);

// save it to file
file_put_contents('avatar.png', $image);

Object-style

<?php

use SandFox\MonsterID\Monster;

$monster = new Monster('[email protected]');

// save it to file
file_put_contents('avatar.png', $monster->build(150));

// or output it to browser
header('Content-type: image/png');
echo build_monster('[email protected]', $monster->build(150));

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