使用 imagettftext 创建的重叠文本字符串

发布于 2024-11-18 05:12:58 字数 463 浏览 5 评论 0原文

我为 png 透明度支持创建了一个图像资源,其内容如下:

$image = imagecreatetruecolor($new_width, $new_height);     
imagealphablending($image, false);
imagesavealpha($image, true);       
$new_image_bg = imagecolorallocatealpha($image, 255, 255, 255, 127);
imagefill($image, 0, 0, $new_image_bg);

然后,我使用 imagettftext() 向该图像资源添加重叠的文本层,但这会覆盖图像的当前区域。我正在尝试将其合并到现有的图像资源中,以保持文本字符串的透明度。以下是我试图避免的示例: 重叠文本图层

I have an image resource created for png transaprency support with the following:

$image = imagecreatetruecolor($new_width, $new_height);     
imagealphablending($image, false);
imagesavealpha($image, true);       
$new_image_bg = imagecolorallocatealpha($image, 255, 255, 255, 127);
imagefill($image, 0, 0, $new_image_bg);

I'm then adding overlapping layers of text to this image resource with imagettftext(), however this overwrites the current area of the image. I'm trying to merge this into the existing image resource maintaining the transparency of the text string. Below is an example of what I'm trying to avoid:
Overlapping text layers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

久随 2024-11-25 05:12:58

一种解决方案是:不要将文本直接放置在目标图像中,而是将其放置在辅助图像中,然后执行 imagecopymerge() 操作。

One solution is: rather than placing text directly in your target image, place it in a secondary image and then perform an imagecopymerge() operation.

岁吢 2024-11-25 05:12:58

您是否为正在制作的图像定义了透明颜色?

Have you defined a transparent colour for the image that you are making?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文