我剛剛剛給出Adaptive Images一槍。自適應圖像/ GD轉換後的tansparent PNG有黑色邊框
它似乎工作正常,除了轉換透明PNG時。我在透明背景上有一個只是彎曲的白色形狀的圖像。當圖像被自適應圖像轉換(我相信它使用GD庫進行轉換)時,白色邊緣形成黑色邊框。
下面是帶黑色邊框的弧形邊緣截圖,以便您明白我的意思。
原稿尺寸1920x63:http://i.imgur.com/Cc0hJ.png
我不知道很多關於GD庫或如何將其轉換圖像,但我沒有做一些摸索,看它是否是我最終的東西。我不認爲它是。
關於同樣的問題,我也發現this similar post。不過,我嘗試編輯自適應圖像PHP使用@WouterH建議的答案,但它沒有奏效。他建議創建一個透明的顏色,並在複製之前用該顏色填充$ image。代碼如下:
$transparent = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagefill($image, 0, 0, $transparent);
imagealphablending($image, true);
的自適應images.php文件,我發現下面的代碼行:
imagealphablending($dst, false);
imagesavealpha($dst,true);
$transparent = imagecolorallocatealpha($dst, 255, 255, 255, 127);
imagefilledrectangle($dst, 0, 0, $new_width, $new_height, $transparent);
這是我做了我的變化。我試了無數的變化,因爲我不知道正確的順序是什麼,但在大多數情況下試了一下沿着這些路線適應的東西:
imagesavealpha($dst,true);
$transparent = imagecolorallocatealpha($dst, 0, 0, 0, 127);
imagefill($image, 0, 0, $transparent);
imagealphablending($dst, true);
imagefilledrectangle($dst, 0, 0, $new_width, $new_height, $transparent);
這似乎沒有任何區別。根據我嘗試過的不同方法,我會在以前透明的任何地方獲得黑色填充,或保留相同的問題(黑色輪廓)。
希望有人可以幫我找出這一個......在此先感謝!
我很難相信它與我如何從Photoshop中保存文件有關。 我另存爲PNG-24,檢查透明度。就這麼簡單。 我只是不明白除了[這傢伙]沒有其他的,除了[這個傢伙]和[這個傢伙](http://stackoverflow.com/questions/8141131/php-gd-resizing-transparent-image-giving-black-border)和[this傢伙](http://stackoverflow.com/questions/11620462/why-does-this-transparent-png-cause-borders-when-combined-using-gd)遇到了這些問題。 這些線程都不提供工作解決方案... – norsewulf