我有一張透明的png圖像,我想製作一張副本然後剪裁成1x1的透明圖像。如何通過腳本修改PNG圖像?
我困在「裁剪爲1x1透明圖像」部分。
我可以修改現有圖像或創建新圖像並覆蓋現有圖像。我相信這兩種選擇都可行。我只是不知道該怎麼做,最終得到1x1像素的透明PNG圖像。
任何幫助非常感謝。
function convertImage(){
$file1 = "../myfolder/image.png";
$file2 = "../myfolder/image-previous.png";
if (!file_exists($file2))
{
//make a copy of image.png and name the resulting file image-previous.png
imagecopy($file2, $file1);
// convert image.png to a 1x1 pixel transparent png
// OR
// create a new 1x1 transparent png and overwrite image.png with it
???
}
}
'imagecopy的()'不上的文件。它適用於GD圖像手柄,你可以使用'imagecreatfrom ...()獲得'如果你想複製一個文件,只需使用'copy()' –
erm,轉換成一個1x1px透明PNG?你有多少細節想象你會打包進去? –
@Kerin,無。這是目標。它有效地從佈局中移除圖像的可視部分,但其唯一設計爲臨時「隱藏」設置。 –