php压缩图片时,原本透明背景的图片最后都变成黑色,解决办法:
$$source_image = 'xxxx.jpg';
//1.创建图片
$target_image = imagecreatetruecolor("水印宽度", "水印高度");
//2.上色
$color=imagecolorallocate($target_image,229,231,230);
//3.设置透明
imagecolortransparent($target_image,$color);
//4.填充
imagefill($target_image,0,0,$color);
//创建一个彩色的底图
imagecopyresampled($target_image, $source_image, 0, 0, 0, 0, "水印宽度", "水印高度", "原图宽度", "原图高度");