hassanalisalem / laravel-initial-image
使用用户名创建默认个人头像的 Laravel 扩展包。
v1.0.2
2016-12-13 18:14 UTC
Requires
- php: >=5.4.0
- intervention/image: 2.*
This package is not auto-updated.
Last update: 2024-09-21 02:10:01 UTC
README
使用名字的前两个字母创建默认个人头像的 Laravel 扩展包。
安装
使用 composer 安装
composer require hassanalisalem/laravel-initial-image
编辑 app/config/app.php
并添加 providers
'providers' => [
'hassanalisalem\Image\DefaultProfileImageServiceProvider'
]
基本用法
要创建个人头像,只需执行以下操作
$img = \DefaultProfileImage::create("Name Surname");
\Storage::put("profile.png", $img->encode());
这将使用名字和姓氏的首字母创建一个 512px 宽度和高度的个人信息头像。
高级用法
创建一个宽度为 216px 和高度为 216px 的黑色背景,白色文字的个人头像。
$img = \DefaultProfileImage::create("Name Surname", 256, '#000', '#FFF');
\Storage::put("profile.png", $img->encode());
使用自定义字体
$img = \DefaultProfileImage::create("@ Lamoni", 256, "#212121", "#FFF", '/var/www/public/fonts/RobotoDraftRegular.woff');
\Storage::put("profile.png", $img->encode());