21,886
社区成员
发帖
与我相关
我的任务
分享
// 合成图片
imagecopymerge($bgimg, $headimg, $logox, 108, 0, 0, $headWidth, $headHight, 100);
// 输出
imagepng($bgimg,UPLOAD_PATH.SEP.'yearbill'.SEP.'123.png');
header('Content-Type: image/jpeg');
ob_clean();
//头像地址
$bcurl = UPLOAD_PATH.SEP.'yearbill'.SEP.$userinfo['openid'].'.jpg';
//创建画布写入图片
$headimg = imagecreatefromstring(file_get_contents($bcurl));
$w = imagesx($headimg);
$h = imagesy($headimg);
$c = imagecolorallocate($headimg, 255, 0, 0);
imagearc($headimg, $w/2, $h/2, $w, $h, 0, 360, $c);
imagefilltoborder($headimg, 0, 0, $c, $c);
imagefilltoborder($headimg, $w, 0, $c, $c);
imagefilltoborder($headimg, 0, $h, $c, $c);
imagefilltoborder($headimg, $w, $h, $c, $c);
imagecolortransparent($headimg, $c);
//获取背景图片
$bg = SKIN_PATH.SEP.images.SEP.'yearbill'.SEP.'result2.png';
$bgimg = imagecreatefromstring(file_get_contents($bg));
//获取图片数据
list($bgWidth, $bgHight, $bgType) = getimagesize($bg);
$url = 'https://avatar.csdn.net/0/B/0/1_pan_y95.jpg';
$im = imagecreatefromstring(file_get_contents($url));
$w = imagesx($im);
$h = imagesy($im);
$c = imagecolorallocate($im, 255, 0, 0);
imagearc($im, $w/2, $h/2, $w, $h, 0, 360, $c);
imagefilltoborder($im, 0, 0, $c, $c);
imagefilltoborder($im, $w, 0, $c, $c);
imagefilltoborder($im, 0, $h, $c, $c);
imagefilltoborder($im, $w, $h, $c, $c);
imagecolortransparent($im, $c); //!!!!
$dm = imagecreatefromstring(file_get_contents('https://img.bbs.csdn.net/upload/201806/26/1529979576_666265.png'));
imagecopymerge($dm, $im, 160, 50, 0, 0, $w, $h, 100);
header("Content-type: image/png");
imagepng($dm);