我有一個PNG圖像我想打開並輸出爲GIF圖像。但是,當我這樣做時,透明度會丟失,背景變黑。如果我將圖像作爲PNG輸出,它可以工作,但我特別需要將圖像作爲PNG打開並將其輸出爲GIF。將PNG轉換爲GIF時的黑色背景
這是我到目前爲止有:
<?php
header("Content-type: image/gif");
$new_img = imagecreatefrompng($image);
imagealphablending($new_img, false);
imagesavealpha($new_img, true);
imagegif($new_img);
?>
然而,imagepng($ new_img)保存背景透明度,但不輸出爲GIF格式。
哦,如果我在第一個地方創建圖像,並做到這一點,它的工作正常。所以這不是我的瀏覽器。從PNG到GIF的過渡讓它變得混亂起來。 – TheEnigmaMachine
@sombe - 「大多數主流瀏覽器都不支持gif中的透明度」,我認爲自1800年以來,所有瀏覽器都支持GIF中的透明度。 – vcsjones