PHP-将PNG转换为JPEG,透明度返回白色背景

时间:2019-05-18 13:15:47

标签: php image png jpeg

我尝试将PNG图片转换为具有透明性的JPG,并且我的代码可以正常使用,但是现在当我尝试使用时,我总是得到带有白色背景的图片。

有什么解决办法吗?

代码:

$input = imagecreatefrompng('test.png');
list($width, $height) = getimagesize('test.png');
$output = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($output,  255, 255, 255);
imagefilledrectangle($output, 0, 0, $width, $height, $white);
imagecopy($output, $input, 0, 0, 0, 0, $width, $height);
imagejpeg($output, $destination, 90);

0 个答案:

没有答案