[英]Transparency issue with png images
I 've got this image: 我有这张图片:
i use php5 and gd2 library to achieve a transparent background, but the result is not what i have expected(you need a dark background to see the difference): 我使用php5和gd2库实现透明背景,但是结果不是我所期望的(您需要深色背景才能看到不同之处):
and here is my code: 这是我的代码:
$size = getimagesize($img_url);
$img = imagecreatefrompng($img_url);
$im_tc = imagecreatetruecolor($size[0],$size[1]);
imagecopyresampled($im_tc,$img,0,0,0,0,$size[0],$size[1],$size[0],$size[1]);
imagedestroy($img);
$white = imagecolorallocatealpha($im_tc, 255, 255, 255,127);
imagecolortransparent($im_tc, $white);
imagepng($im_tc,'image.png');
Any help would be appreciated! 任何帮助,将不胜感激! :)
:)
Your original image doesn't have a transparent background, but you're trying to create one by changing all pure-white pixels to transparent. 您的原始图像没有透明背景,但是您尝试通过将所有纯白色像素更改为透明来创建背景。 As the text has a shadow/glow around it, those pixels aren't quite white, and won't become transparent.
由于文本周围有阴影/发光,因此这些像素不是很白,也不会变得透明。 You have a couple options here:
您在这里有几个选择:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.