干预图像水印文字

问题描述

我无法使用干预图像插入文本水印。 运行脚本后,我得到了没有文本水印的源图像。

$img = Image::make($infile)->resize(1024,768,function ($constraint) 
{
    $constraint->aspectRatio();
    $constraint->upsize();
});

$img->text('watermark text',function ($font) {
    $font->file(public_path('storage/fonts/DejaVuSans.ttf'));
    $font->size(24);
    $font->color(array(255,255,0.3));
    $font->align('center');
    $font->valign('top');
    $font->angle(0);
});

$img->save($outfile);

我在 \mysite\storage\app\public\fonts 有 DejaVuSans.ttf 我有符号链接 public_path('storage') => storage_path('app/public') 所以公共路径 storage/fonts 应该指向 /storage/app/public/fonts。 至少对于位于 /storage/app/public/img 中的图像,我使用 public_path('storage/img/mypic.jpg') 并且它有效。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)