0

私はこの質問への答えと非常によく似た(同じことをする)コードを使用しています:Crop whitespace from image in PHP。同じ効果で、この正確なコードも試しました:

PNGの背景が真の白(透明ではない)であっても、PNGソースでは機能しない(空白をトリミングしない)ことがわかりました。出力をimagepng問題なく に送信できますが、画像ソースが の場合imagecreatefrompng、何もトリミングされません。

GD を使用して PNG から空白をトリミングする信頼できる方法はありますか? または、白を透明に変換して代わりにトリミングする方法はありますか? それとも、他の解決策...?

4

1 に答える 1

0

This is a totally untested guess. However, I would assume that alpha transparency is causing the issue. The answer that you mentioned might need a bit of work.

Perhaps try using imagecopymerge() to lay the image over a white canvas, and then go through the steps mentioned in the answer.

于 2012-05-20T11:38:09.430 に答える