vinicius73/laravel-instantavatar

此包最新版本(v1.1.0)没有提供许可证信息。

轻松创建非常漂亮的随机头像。Laravel 包

v1.1.0 2015-10-04 04:28 UTC

This package is auto-updated.

Last update: 2024-09-13 03:09:03 UTC


README

轻松创建非常漂亮的随机头像。

安装

在您的 composer.json 中添加新要求的包

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

运行 composer updatephp 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

扁平

基于 avatarly 的颜色

Instant Avatar Flat