如何在Laravel中使用图像干预在图像中创建曲线(圆角)文本?

时间:2019-12-05 08:26:26

标签: laravel image intervention

我已经使用laravel中的Intervention创建了图像(下面的链接)。 https://i.stack.imgur.com/DPmee.jpg https://i.stack.imgur.com/HycjA.jpg

但是我需要在QR上方和下方添加曲线文本(URL),如下图所示(请参见黑色QR标签): https://i.stack.imgur.com/PaSPt.jpg

这是创建图像的代码。

> public function tag()
>      {
> 
>         $bgColor = '#000000';
>         $textColor = '#ffffff';
>     
>         $img = Image::canvas(192, 192);
>         $img->circle(192, 96, 96, function ($draw) use ($bgColor) {
>             $draw->background($bgColor);
>         });
>         $img1 = Image::canvas(192, 192);
>         $img1->circle(192, 96, 96, function ($draw) use ($bgColor) {
>             $draw->background($bgColor);
>         });
> 
> 
>         $fontPathExtraBold = public_path('fonts/Raleway/Raleway-ExtraBold.ttf');
>         $fontPathBold = public_path('fonts/Raleway/Raleway-Bold.ttf');
>         $fontPathSemiBold = public_path('fonts/Raleway/Raleway-SemiBold.ttf');
>         $fontPathLight = public_path('fonts/Raleway/Raleway-Light.ttf');
> 
> 
>         $img1->text('ROCCO', 96, 50, function ($font) use ($fontPathExtraBold, $textColor) {
>             $font->file($fontPathExtraBold);
>             $font->size(18);
>             $font->color($textColor);
>             $font->align('center');
>         });
> 
>         $img1->text('12345', 96, 75, function ($font) use ($textColor, $fontPathExtraBold) {
>             $font->file($fontPathExtraBold);
>             $font->size(16);
>             $font->color($textColor);
>             $font->align('center');
>         });
>         $img1->text('SCAN OR BROWSE:', 96, 100, function ($font) use ($textColor, $fontPathExtraBold) {
>             $font->file($fontPathExtraBold);
>             $font->size(16);
>             $font->color($textColor);
>             $font->align('center');
>         });
>         $img1->text('PET-ID.APP/RFP/12345', 96, 125, function ($font) use ($textColor, $fontPathExtraBold) {
>             $font->file($fontPathExtraBold);
>             $font->size(13);
>             $font->color($textColor);
>             $font->align('center');
>         });
>       
>         //QR Code
>         $qrCode = url('/qrcode.png');
>         // Insert QR Code
>         $insertQr = Image::make($qrCode)->resize(122, 122);
>         $img->insert($insertQr, 'center');
> 
>   
> 
>         $fileName = uniqid('', true);
>         $fileName1 = uniqid('', true);
>         $fileName2 = uniqid('', true);
> 
>         $saveimg = storage_path('app/public/tag/image/' . $fileName . '.jpg');
>         $saveimg1 = storage_path('app/public/tag/image/' . $fileName1 . '.jpg');
>   
>         $img->save($saveimg);
>         $img1->save($saveimg1);
> 
>         $savepdf = storage_path('app/public/wallpaper/' . $fileName . '.pdf');
>         $savepdf1 = storage_path('app/public/wallpaper/' . $fileName1 . '.pdf');
> 
>         PDF::loadHTML("<img src='" . $saveimg . "'>")->save($savepdf);
>         PDF::loadHTML("<img src='" . $saveimg1 . "'>")->save($savepdf1);
>         return 'done';
>     }

0 个答案:

没有答案
相关问题