>到处都在谈论在透明图像上添加文本。我已经成功添加了水印等文本(所以意味着透明文本)。你能建议我如何给不透明度 50% 吗?
这是代码 -
$text = "GIF-KING";
$font = "arial.ttf";
$image = imagecreatefromgif('tmpimg/myimage.gif');
$text_color = imagecolorallocate($image, 198, 60, 147);
//imagestring($image,36, 10, 20, $text, $text_color);
imagettftext($image, 30, 0,10, 290, $text_color, $font, $text);
你需要imagecolorallocatealpha
而不是imagecolorallocate
,Alpha 混合不是 100% 可用的,因此请注意错误消息。
imagecolorallocatealpha() 的行为与 imagecolorallocate() 相同 添加了透明度参数阿尔法。
http://php.net/imagecolorallocatealpha