ThinkPHP5 添加多个文字水印及疑难解答

    public function imageload()
    {
        $imgpath = ROOT_PATH . 'public' . DS . 'static' . DS . 'www' . DS . 'img' . DS . 'certificate.png';
        $ttfpath = ROOT_PATH . 'public' . DS . 'static' . DS . 'www' . DS . 'fonts' . DS . 'msyh.ttf';
        $image = \think\Image::open($imgpath);
        // 给原图左上角添加水印并保存water_image.png
        $image
        ->text("这是内容1", $ttfpath, 14, '#000000',[400,377])
        ->text("这是内容1", $ttfpath, 14, '#000000',[400,435])
        ->text("这是内容1", $ttfpath, 14, '#000000',[400,493])
        ->text("这是内容1", $ttfpath, 14, '#000000',[400,551])
        ->text("这是内容1", $ttfpath, 14, '#000000',[810,335])
        ->save('text_image.png');
    }

生成多个水印只需要调用多个text方法便可实现,但我翻阅很多博客与文档都没写这种方法

报错文件不存在的同志将图片及字体写成绝对路径

请先composer下载图片类 composer require topthink/think-image

猜你喜欢

转载自www.cnblogs.com/wxzxc/p/9780645.html