我使用此代碼從另一個png圖片創建一個圖像,該背景是黑色默認情況下。我的問題是如何設置透明背景?PHP imagecopy的具有透明背景
$input = imagecreatefrompng('image.png');
$output = imagecreatetruecolor(50, 50);
imagecopy($output, $input, 4,0, 8,8, 8,8);
imagecopy... etc.
header('Content-Type: image/png');
imagepng($output);
有沒有簡單的方法做到這一點?由於
是的!這工作:'$黑色= imagecolorallocate($輸出,0,0,0); 了imagecolortransparent($輸出,$黑色);'之前imagecopy的 – 2by