工作中需要縮放一些gif圖然后在去imagecopymerge,可是發(fā)現(xiàn)使用了imagecreatetruecolor和imagecopyresampled后發(fā)現(xiàn)背景圖不對(duì),本來透明的背景圖變成了黑色,后來發(fā)現(xiàn)做一些修改才可以:
$img = imagecreatetruecolor(200, 200);
//2.上色
$color=imagecolorallocate($img,255,255,255);
//3.設(shè)置透明
imagecolortransparent($img,$color);
imagefill($img,0,0,$color);
然后再進(jìn)行imagecopyresampled和imagecopymerge就沒有問題了
更多信息請(qǐng)查看IT技術(shù)專欄