vinicius73/Laravel-InstantAvatar

语言: PHP

git: https://github.com/vinicius73/Laravel-InstantAvatar

轻松创建一个非常漂亮的随机化身。
Create a very pretty random avatars with ease.
README.md (中文)

Laravel - 即时头像

轻松创建一个非常漂亮的随机化身。

安装

在composer.json中添加新的必需包

"vinicius73/laravel-instantavatar": "~1.1"

运行composer update或php composer.phar update。

在composer命令之后,在app / config / app.php中添加新的服务提供者:

Vinicius73\IAvatar\IAvatarServiceProvider::class,

现在,在app / config / app.php中添加新别名。

'IAvatar' => Vinicius73\IAvatar\Facade\IAvatarFacade::class,

最后发布php artisan vendor:publish包的配置文件

用法

/**
 * Creates the image. Only the first letter will be passed to the image.
 * Ex.:
 * 'My String' -> output My
 * You can change this in the settings
 */
$avatar = IAvatar::random('My String');

/**
 * Save imagem in path
 * You can use `public::` Omit the full address /public
 */
$avatar->save('public::path/to/file.png');

/**
 * Output image in browser
 */
$avatar->display();
IAvatar::random('Vinicius')->save('public::avatars/vinicius.png')->display();

组态

return array(
    'width'    => 150,
    'heigth'   => 150,
    'fontsize' => 80, // in px
    'chars'    => 2, // Character limit for every image
    'font' => array( // You can register or remove more sources with ease.
        'InstantAvatar::Comfortaa-Regular.ttf',
        'InstantAvatar::Roboto-Regular.ttf',
        'InstantAvatar::Ubuntu-Regular.ttf',
        'InstantAvatar::DroidSans.ttf'
    ),
    'overlay'  => 'InstantAvatar::glass.png', // A watermark that overlays the image
    'flat'     => false // Enables the flat mode
);

演示

默认

Instant Avatar

平面

颜色基于化身

Instant Avatar Flat

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

Laravel - Instant Avatar

Create a very pretty random avatars with ease.

installation

Add the new required package in your composer.json

"vinicius73/laravel-instantavatar": "~1.1"

Run composer update or php composer.phar update.

After composer command, add new service provider in app/config/app.php :

Vinicius73\IAvatar\IAvatarServiceProvider::class,

Now, add new aliases in app/config/app.php.

'IAvatar' => Vinicius73\IAvatar\Facade\IAvatarFacade::class,

Finally publish the configuration file of the package php artisan vendor:publish

Usage

/**
 * Creates the image. Only the first letter will be passed to the image.
 * Ex.:
 * 'My String' -> output My
 * You can change this in the settings
 */
$avatar = IAvatar::random('My String');

/**
 * Save imagem in path
 * You can use `public::` Omit the full address /public
 */
$avatar->save('public::path/to/file.png');

/**
 * Output image in browser
 */
$avatar->display();
IAvatar::random('Vinicius')->save('public::avatars/vinicius.png')->display();

Configuration

return array(
    'width'    => 150,
    'heigth'   => 150,
    'fontsize' => 80, // in px
    'chars'    => 2, // Character limit for every image
    'font' => array( // You can register or remove more sources with ease.
        'InstantAvatar::Comfortaa-Regular.ttf',
        'InstantAvatar::Roboto-Regular.ttf',
        'InstantAvatar::Ubuntu-Regular.ttf',
        'InstantAvatar::DroidSans.ttf'
    ),
    'overlay'  => 'InstantAvatar::glass.png', // A watermark that overlays the image
    'flat'     => false // Enables the flat mode
);

Demo

Default

Instant Avatar

Flat

Color based in avatarly

Instant Avatar Flat