修复文字水印透明度不生效

This commit is contained in:
icret
2022-03-12 14:19:45 +08:00
parent 736588e98d
commit d2ce0a2470
7 changed files with 26 additions and 9 deletions

View File

@@ -285,7 +285,8 @@ class Imgs
return array('code' => false, 'msg' => '请给正确的字体颜色');
}
$def['color'] = imagecolorallocatealpha($dst_img, $rgb[0], $rgb[1], $rgb[2], $rgb[3]);
// ceil(127 - 127 * $rgb[3]) 将CSS中的Alpha 0-1 转换为PHP Alpha 127-0 并取整
$def['color'] = imagecolorallocatealpha($dst_img, $rgb[0], $rgb[1], $rgb[2], ceil(127 - 127 * $rgb[3]));
imagettftext(
$dst_img,
$def['fontSize'],

View File

@@ -39,7 +39,7 @@ function water($source)
'name' => $source,
'font' => APP_ROOT . $config['textFont'],
'fontSize' => $config['textSize'],
'color' => $config['textColor'],
'color' => str_replace(array('rgba', '(', ')'), '', $config['textColor']),
];
Imgs::setWater($source, $arr);
}