下载源码包括下载的英文字体和thinkphp5中的Image.php修复文件,直接覆盖即可 thinkphp5部分图片水印报错Failed to create image resources PHP7.3水印BUG
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 下载直接替换即可。
系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791