脚本宝典收集整理的这篇文章主要介绍了PHP-GD:保留半透明区域,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用此代码:
function resize($width,$height) { $new_image = imagecreatetruecolor($width,$height); if($this->image_tyPE == PNG or $this->image_type == GIF) { imagealphablending($new_image,false); imagesavealpha($new_image,true); $transparent = imagecolorallocatealpha($new_image,255,127); imagefilledrectangle($new_image,$nWidth,$nHeight,$transparent); } imagecopyresized($new_image,$this->image,$width,$height,$this->getWidth(),$this->getHeight()); $this->image = $new_image; }
但是,当我上传的图像区域的alpha值介于0到255之间时,它们会被完整的黑色替换,将抗锯齿区域变为黑色边框.
完全透明度适用于PNG和GIF,只有半透明区域是个问题.
如果我没有使用正确的术语来解释我的问题,我很抱歉,也许这就是为什么我几乎找不到任何东西.
以上是脚本宝典为你收集整理的PHP-GD:保留半透明区域全部内容,希望文章能够帮你解决PHP-GD:保留半透明区域所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。