How do i get a transparent background after rotaing a png image with php?

前端 未结 7 1255
天命终不由人
天命终不由人 2020-12-19 10:38

So I have png image and I rotate it but i get a black background.. or if i do the color code ofr white i get white.. I tried doing this..

$trans = imagecol         


        
7条回答
  •  独厮守ぢ
    2020-12-19 11:03

    $destimg = imagecreatefromjpeg("image.png");
    $transColor = imagecolorallocatealpha($destimg, 255, 255, 255, 127);
    $rotatedImage = imagerotate($destimg, 200, $transColor);
    imagesavealpha($rotatedImage, true);
    imagepng($rotatedImage,"rotated.png");
    

提交回复
热议问题