|
@@ -11,6 +11,7 @@ use App\Traits\CommunityTrait;
|
|
|
use Intervention\Image\Facades\Image;
|
|
|
use Intervention\Image\ImageManagerStatic;
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
+use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
|
|
|
|
|
class PosterRepository
|
|
|
{
|
|
@@ -35,6 +36,7 @@ class PosterRepository
|
|
|
if(!$postDetail){
|
|
|
return jsonError('获取内容信息失败');
|
|
|
}
|
|
|
+
|
|
|
// 设置头像
|
|
|
if(!$userInfo['avatar']){
|
|
|
$userInfo['avatar'] = 'https://wx.qlogo.cn/mmopen/vi_32/DYAIOgq83ep3asJn8emiat1MnPdviaPNroWY3f65y5ezkTAk2qtibv7ea9Ht9R2ahxr9bicY1DIj5vN5FibpDOwXegg/132';
|
|
@@ -52,7 +54,7 @@ class PosterRepository
|
|
|
$this->main->insert($mask, 'left-top', 0, 0);
|
|
|
|
|
|
//logo
|
|
|
- $mask = ImageManagerStatic::make(public_path('/image/post/logo.png'))->fit(73, 19);
|
|
|
+ $mask = ImageManagerStatic::make(public_path('/image/post/logo.png'))->fit(145, 38);
|
|
|
$this->main->insert($mask, 'left-top', 55, 60);
|
|
|
|
|
|
//话题
|
|
@@ -66,8 +68,14 @@ class PosterRepository
|
|
|
}
|
|
|
|
|
|
//标题或内容
|
|
|
-// $title = '今天气不错去看看吧';
|
|
|
- $title = '今天气不错去看看吧,今天气不错去看看吧,今天气不错去看看吧,今天气不错去看看吧,今天气不错去看看吧';
|
|
|
+ if($postDetail['title']){
|
|
|
+ $title = $postDetail['title'];
|
|
|
+ }else{
|
|
|
+ $title = $postDetail['content'];
|
|
|
+ if($postDetail['type'] == 'html'){
|
|
|
+ $title = strip_tags($postDetail['content']);
|
|
|
+ }
|
|
|
+ }
|
|
|
$title = subtext($title, 34);
|
|
|
if(mb_strlen($title, 'utf8') > 17){
|
|
|
$title = mb_substr($title, 0, 17, 'utf8')."\n".mb_substr($title, 17, -1, 'utf8').' ...';
|
|
@@ -116,6 +124,13 @@ class PosterRepository
|
|
|
}
|
|
|
|
|
|
$this->main->insert($new, 'top-left', 105, 436);
|
|
|
+
|
|
|
+ $qrcode = Image::make(QrCode::format('png')->generate('https://www.jianshu.com/p/1c78294f26f8'));
|
|
|
+
|
|
|
+ $qrcode->resize(164,164);
|
|
|
+
|
|
|
+ $this->main->insert($qrcode,'top-left', 63, 1087);
|
|
|
+
|
|
|
$path = '/public/post'.$id.'.png';
|
|
|
// $image->save($path);
|
|
|
//$url = config('filesystems.disks.oss.uri').$path;
|