2017 © Pedro Peláez
 

library identicon

A PHP library for generating identicons.

image

fivenp/identicon

A PHP library for generating identicons.

  • Thursday, March 22, 2018
  • by fivenp
  • Repository
  • 1 Watchers
  • 1 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

PHP-Identicons

PHP-Identicons is a lightweight PHP implementation of Don Park's original identicon code for visual representation of MD5 hash values. The program uses the PHP GD library for image processing., (*1)

The code can be used to generate unique identicons, avatars, and system-assigned images based on a user's e-mail address, user ID, etc., (*2)

INSTALLATION

Install using composer:, (*3)

$ composer require fivenp/identicon

USAGE

Basic usage

The code below, will create an identicon from the string "TEST", and save it to identicon.png., (*4)

<?php

use Fivenp\Identicon\Identicon;

$identicon = new Identicon(md5('TEST'));
$icon = $identicon->create();
file_put_contents('identicon.png', $icon);

There's also a shorter version of doing this:, (*5)

<?php

use Fivenp\Identicon\Identicon;

file_put_contents('identicon.png', (new Identicon(md5('TEST')))->create());

Advanced usage

You can overwrite some basic settings by passing an options array., (*6)

<?php

use Fivenp\Identicon\Identicon;

$options = array(
    'size'=>2048, // a value between 16 and 2048 is accepted
    'backgroundColor'=>array( // must be in red/green/blue
        "red" => "255",
        "green" => "255",
        "blue" => "255",
    ),
);

$identicon = new Identicon(md5('TEST'),$options);
$icon = $identicon->create();

Even more advanced options

You can also overwrite some more advanced settings, (*7)

<?php

use Fivenp\Identicon\Identicon;

$options = array(
    'size'=>2048, // a value between 16 and 2048 is accepted
);

$identicon = new Identicon(md5('TEST'),$options);

// A cusom color palette where the generator is using the colors randomly from
$identicon->palette = array(
    'orange' => '#ff944e',
    'red' => '#e84c3d',
    'blue' => '#3598db',
    'black' => '#000000',
    'white' => '#ffffff',
);

// A cusom color palette where the generator is using the backgroundColor randomly from
$identicon->availableBackgroundColors = array(
    'white',
    'red',
);

$icon = $identicon->create();

LICENSE

PHP-Identicons is distributed under the GPLv3 License., (*8)

HISTORY

This code was forked from Timo van Neerden project page on Github which was originnially created by Bong Costa in 2009., (*9)

It has been forked from its project page on SourceForge as I intend to enhance it a bit for personnal usage., (*10)

The Versions

22/03 2018

dev-master

9999999-dev

A PHP library for generating identicons.

  Sources   Download

GPL-3.0-only

The Requires

  • php >=5.4.0

 

by Michael Henning

22/03 2018

0.2.3

0.2.3.0

A PHP library for generating identicons.

  Sources   Download

GPL-3.0-only

The Requires

  • php >=5.4.0

 

by Michael Henning

22/03 2018

0.2.2

0.2.2.0

A PHP library for generating identicons.

  Sources   Download

GPL-3.0-only

The Requires

  • php >=5.4.0

 

by Michael Henning

20/03 2018

0.2.1

0.2.1.0

A PHP library for generating identicons.

  Sources   Download

GPL-3.0-only

The Requires

  • php >=5.4.0

 

by Michael Henning

20/03 2018

v0.1.0

0.1.0.0

A PHP library for generating identicons.

  Sources   Download

GPL-3.0-only

The Requires

  • php >=5.4.0

 

by Michael Henning

20/03 2018

0.2.0

0.2.0.0

A PHP library for generating identicons.

  Sources   Download

GPL-3.0-only

The Requires

  • php >=5.4.0

 

by Michael Henning