群信息生成图片php

群信息生成图片php

成精的宅货ゝ
2020-12-23 / 0 评论 / 741 阅读 / 正在检测是否收录...

用php生成图片
2020-12-23-20-45-01.png

代码:

function 信息($昵称, $QQ, $进群, $退群, $到期){
    $图片 = imagecreatetruecolor(250, 380); //创建图片
    $头像=imagecreatefromstring(file_get_contents("https://q2.qlogo.cn/headimg_dl?dst_uin={$QQ}&spec=640"));
    $颜色 = [imagecolorallocate($图片, 255, 255, 255),imagecolorallocate($图片, 17, 142, 255),imagecolorallocate($图片, 255, 50, 50) ];
    imagefill($图片, 0, 0, $颜色[0]);
    $字体 = realpath("simsun.ttc");
    
    imagecopyresized($图片,$头像,5,5,0,0,240,240,imagesx($头像),imagesy($头像));
    imagettftext($图片,12,0, 10 ,270,$颜色[1],$字体,"{$昵称} [{$QQ}]");
    imagettftext($图片,12,0, 10 ,290,$颜色[1],$字体,'进群时间:'.$进群);
    imagettftext($图片,12,0, 10 ,310,$颜色[1],$字体,'退群时间:'.$退群);
    imagettftext($图片,12,0, 10 ,330,$颜色[1],$字体,'到期时间:'.$到期);
    imagettftext($图片,12,0, 10 ,370,$颜色[2],$字体,'到期时间仅是易改到期!');
    
    //直接输出图片
    //header("Content-Type:image/png");
    //imagepng($图片);
    
    //写出文件
    $图片名 = date("Y-m-d-H-i-s") . '.png';
    imagepng($图片,"files/".$图片名);
    //销毁...
    imagedestroy($图片);
    imagedestroy($头像);
    return "https://www.lxinyu.cn/files/".$图片名;
}
-1

评论

博主关闭了所有页面的评论