PHP GD - Transparent areas goes black

独自空忆成欢 提交于 2019-12-05 08:05:47

You should call these two functions before saving the png image, imagealphablending() and imagesavealpha():

imagealphablending( $image, false );
imagesavealpha( $image, true );
Ross

This answer suggests two things:

  • imagealphablending should be set to false in order to preserve alpha channels
  • You should set the colour you want transparent (in this case black) as transparent:
$black = imagecolorallocate($image, 0, 0, 0);
imagecolortransparent($image, $black);

Do these help?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!