我打算使用 php gd 旋转透明颜色的图像。但是旋转之后,图像中的透明色不再透明,背景也不透明了。这是我的代码。
$im = imagecreatefromgif('/images/80-2.gif');
$rotate = imagerotate($im,30,imagecolorallocatealpha($im, 0, 0, 0, 127));
imagegif($rotate,'/images/rotate.gif');
imagedestroy($im);
imagedestroy($rotate);
有人可以帮助我让它工作吗?谢谢。
最佳答案
为了保持图像的透明度,您需要使用两个设置,这两个设置可以通过在创建 gd 资源后立即调用这些函数来完成
imagealphablending( $im, false );
imagesavealpha( $im, true );
关于php - 以透明颜色旋转图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14633001/