定制 fivenp/identicon 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fivenp/identicon

Composer 安装命令:

composer require fivenp/identicon

包简介

A PHP library for generating identicons.

README 文档

README

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.

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.

INSTALLATION

Install using composer:

$ composer require fivenp/identicon

USAGE

Basic usage

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

<?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:

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

<?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

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

HISTORY

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

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

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2018-03-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固