定制 runmybusiness/initialcon 二次开发

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

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

runmybusiness/initialcon

最新稳定版本:0.1.3

Composer 安装命令:

composer require runmybusiness/initialcon

包简介

Create a GMail esque avatar based on the users intials & a persistant identifier such as an email address.

README 文档

README

Build Status StyleCI Latest Stable Version Total Downloads Latest Unstable Version License

Initialcon example #1   Initialcon example #2   Initialcon example #3  

Installation

The recommended way to install Initialcon is through composer.

Just create a composer.json file for your project:

{
    "require": {
        "runmybusiness/initialcon": "*"
    }
}

And run these two commands to install it:

$ wget http://getcomposer.org/composer.phar
$ php composer.phar install

Now you can add the autoloader (if your framework doesn't already do this for you), and you will have access to the library:

<?php

require 'vendor/autoload.php';

You're done.

Usage

Images are generated in PNG format with a colored background & the initials in white text.

The string can be an email, an IP address, a username, an ID or something else that is persistant between page loads. This string determines the color of the icon background and will persist between pageloads so long as the string doesnt change.

Generate an initialcon

Create a new Initialcon object.

$initialcon = new Initialcon();

Then you can generate and display an initialcon image

$initialcon->displayImage('TS', 'tom@test.com');

or generate and get the image data

$imageData = $initialcon->getImageData('TS', 'tom@test.com');

or generate and get the base 64 image uri ready for integrate into an HTML img tag.

$imageDataUri = $initialcon->getImageDataUri('HI', 'hello@test.com');
<img src="<?php echo $imageDataUri; ?>" alt="bar Initialcon" />

Change the size

By default the size will be 64 pixels. If you want to change the image size just add a secondary parameter. 512 x 512px in this example.

$initialcon->displayImage('TS', 'tom@test.com', 512);

Color

The color is automaticaly generated according to the string hash but you can chose to specify a color by adding a third argument.

Color can be an hexadecimal with 6 characters

$initialcon->displayImage('TS', 'tom@test.com', 64, 'A87EDF');

Image Object

You can also grab the Image object to add more manipulation to the final icon (such as rounded corders, opacity, etc). We use the Intervention library for image creation so all of its' methods are available to you.

$initialcon->getImageObject('TS', 'tom@test.com', 512);

That's it!

Unit Tests

To run unit tests, you'll need and a set of dependencies you can install using Composer:

php composer.phar install

Once installed, just launch the following command:

phpunit

Everythings should be ok.

Credits

License

Initialcon is released under the MIT License. See the bundled LICENSE file for details.

统计信息

  • 总下载量: 16.82k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 94
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 94
  • Watchers: 8
  • Forks: 94
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-05-26