//重点代码 //拷贝头像到新画布 $newhead = imageCreatetruecolor(180,180);//新建白板,头像 imagesavealpha($newhead, true); $color = imagecolorallocatealpha($newhead, 255, 255, 255,127); imagecolortransparent($newhead,$color); imagefill($newhead, 0, 0, $color); imagecopyresampled($newhead,$image,20,20,0,0,imagesx($image),imagesy($image),imagesx($image),imagesy($image)); //新建画布拷贝数字背景 $num_bg="./Public/Images/icon-head2.png"; $num_bg_src = imagecreatefrompng($num_bg); $num_bg_new = imageCreatetruecolor(imagesx($num_bg_src),imagesy($num_bg_src)); imagesavealpha($num_bg_new, true); //为真彩色画布创建白色背景,再设置为透明 $color = imagecolorallocatealpha($num_bg_new, 255, 255, 255,127); imagecolortransparent($num_bg_new,$color); imagefill($num_bg_new, 0, 0, $color); imagecopyresampled($num_bg_new,$num_bg_src,0,0,0,0,imagesx($num_bg_new),imagesy($num_bg_new),imagesx($num_bg_new),imagesy($num_bg_new));