浏览代码

邀请海报

wzq 5 年之前
父节点
当前提交
2f92ded9c8
共有 3 个文件被更改,包括 22 次插入20 次删除
  1. 1 1
      app/Helper/helper.php
  2. 21 19
      app/Repositories/PosterRepository.php
  3. 二进制
      public/image/invite/main.png

+ 1 - 1
app/Helper/helper.php

@@ -139,7 +139,7 @@ function http($url, $param, $method = 'post')
 function subtext($text, $length)
 {
     if(mb_strlen($text, 'utf8') > $length) {
-        return mb_substr($text, 0, $length - 1, 'utf8');
+        return mb_substr($text, 0, $length - 1, 'utf8').'...';
     } else {
         return $text;
     }

+ 21 - 19
app/Repositories/PosterRepository.php

@@ -81,7 +81,7 @@ class PosterRepository
         }
         $title = subtext($title, 34);
         if(mb_strlen($title, 'utf8') > 17){
-            $title = mb_substr($title, 0, 17, 'utf8')."\n".mb_substr($title, 17, -1, 'utf8').' ...';
+            $title = mb_substr($title, 0, 17, 'utf8')."\n".mb_substr($title, 17, -1, 'utf8');
             $height = 380;
         }else{
             $height = 350;
@@ -156,12 +156,12 @@ class PosterRepository
         $main = ImageManagerStatic::make($mainImg);
 
         // U米数
-        $beanWidth = 194;
-        if(strlen($bean) == 4) $beanWidth = 182;
-        $main->text($bean, $beanWidth, 1060, function ($font) {
+        $beanWidth = 180;
+        if(strlen($bean) == 4) $beanWidth = 168;
+        $main->text($bean, $beanWidth, 1014, function ($font) {
             $font->file(public_path('font/PingFang Bold.ttf'));
-            $font->size(36);
-            $font->color('#C74A48');
+            $font->size(34);
+            $font->color('#0CD4C0');
             $font->align('left');
         });
 
@@ -173,28 +173,30 @@ class PosterRepository
             for($i=0;$i<6;$i++){
                 if($str[$i] != $strLower[$i]) $upperNumber++;
             }
-            $codeWidth = 212 - $upperNumber * 3;
-            $main->text($str, $codeWidth, 912, function ($font) {
-                $font->file(public_path('font/PingFang Regular.ttf'));
-                $font->size(28);
-                $font->color('#3C5852');
+            $codeWidth = 592 - $upperNumber * 3;
+            $main->text($str, $codeWidth, 892, function ($font) {
+                $font->file(public_path('font/PingFang Bold.ttf'));
+                $font->size(32);
+                $font->color('#0CD4C0');
                 $font->align('left');
             });
         }
 
         // 用户名称
         if($userInfo['username']){
-            $main->text(filter_Emoji($userInfo['username']), 30, 860, function ($font) {
-                $font->file(public_path('font/PingFang Regular.ttf'));
-                $font->size(28);
-                $font->color('#3C5852');
+            $userName = filter_Emoji($userInfo['username']);
+            $userName = subtext($userName, 9);
+            $main->text($userName, 40, 892, function ($font) {
+                $font->file(public_path('font/PingFang Bold.ttf'));
+                $font->size(32);
+                $font->color('#333333');
                 $font->align('left');
             });
         }
 
         // 用户头像
         if($userInfo['avatar']){
-            $avatar = Image::make($userInfo['avatar'])->resize(88,88);
+            $avatar = Image::make($userInfo['avatar'])->resize(100,100);
             $new= Image::canvas(750, 1346);
             $r=$avatar->width() /2;
             for($x=0;$x<$avatar->width();$x++) {
@@ -210,14 +212,14 @@ class PosterRepository
                 }
             }
 
-            $main->insert($new, 'top-left', 30, 717);
+            $main->insert($new, 'top-left', 40, 744);
         }
 
         $qrcode = Image::make(QrCode::format('png')->generate(config('customer.share_invite_h5url')."?invite_code={$userInfo['invite_code']}"));
 
-        $qrcode->resize(170,170);
+        $qrcode->resize(140,140);
 
-        $main->insert($qrcode,'top-left', 547, 944);
+        $main->insert($qrcode,'top-left', 570, 1164);
 
         // 存储图片
         $filename = date('Ym').'/'.time() . '_' . uniqid() . '.jpg';

二进制
public/image/invite/main.png