Thinkphp5英文网址文字水印并解决水印BUG【原创

来源:https://www.sucaihuo.com/php/5286.html 2021-05-07 17:00浏览(1386) 收藏

下载源码包括下载的英文字体和thinkphp5中的Image.php修复文件,直接覆盖即可 thinkphp5部分图片水印报错Failed to create image resources PHP7.3水印BUG
Thinkphp5英文网址文字水印并解决水印BUG
分类:PHP > Thinkphp 难易:初级
查看演示 下载资源 下载积分: 100 积分

Thinkphp5水印方法如下,根据图片宽度设置字体大小

$image = \think\Image::open($temp);
$img_size = getimagesize($temp);
$width = $img_size[0];
$font_size = 35;
if ($width <= 600 && $width >= 500) {
    $font_size = 30;
} elseif ($width <= 500) {
    $font_size = 22;
}
$image->text('www.jiuniao.com/store/1, ROOT_PATH . "/public/static/font/Elitakoo.ttf", $font_size, '#ec0d01', 5, 0, 0)->save($temp_water);

Thinkphp5文字水印报错,抛出异常:Failed to create image resources,仔细发现是函数imagecreatefrompng报错如下:

imagepng(): gd-png: fatal libpng error: Incompatible libpng version in application and library

解决方案一:查看系统libpng版本 通过phpinfo查询,更换libpng版本

解决方案二,对应个别图片,没法水印的,不做任何处理,\vendor\topthink\think-image\src\Image.php 下载直接替换即可。

标签: 水印
声明:本文为原创文章,如需转载,请注明来源sucaihuo.com并保留原文链接:https://www.sucaihuo.com/php/5286.html
评论0
头像

系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791

1 2