tpadmin合成推广二维码

合成推广二维码

$img_url = $this->getCode("{$userId}");
                $name = ROOT_PATH."/public/code/" . $this->get_random();
                $code_filename = \File::downloadImage($img_url, $name);
                $head_url = Db::table('tp_wy_users')->where('id',$userId)->value('head_url');

                if (empty($head_url)) {
                    $head_filename = ROOT_PATH.'public/static/baseimg/head.jpg';
                }else{
                    $name = ROOT_PATH."/public/code/" . $this->get_random();
                    $this->download($head_url,$name.'.jpg');
                    $head_filename = $name.'.jpg132';//132不知道是什么
                };

                $imgs = array(
                        'base' => ROOT_PATH.'public/static/baseimg/base.jpg',
                        'code' => $code_filename,
                        'head' => $head_filename,
                );

                list($max_width, $max_height) = getimagesize($imgs['base']);
                $dests = imagecreatetruecolor($max_width, $max_height);
                $dst_im = imagecreatefromjpeg($imgs['base']);
                imagecopy($dests,$dst_im,0,0,0,0,$max_width,$max_height);
                imagedestroy($dst_im);
                $src_im = imagecreatefromjpeg($imgs['code']);
                $src_info = getimagesize($imgs['code']);
                imagecopy($dests,$src_im,110,480,0,0,$src_info[0],$src_info[1]);
                imagedestroy($src_im);

                $head_type = getimagesize($imgs['head']); 
                switch ($head_type['mime']) { 
                    case "image/jpeg": 
                        $src_im2 = imagecreatefromjpeg($imgs['head']);
                        break; 
                    case "image/png": 
                        $src_im2 = imagecreatefrompng($imgs['head']);
                        break; 
                       default:
                    $src_im2 = imagecreatefromjpeg($imgs['head']);
                } 
                $src_info2 = getimagesize($imgs['head']);
                imagecopy($dests,$src_im2,20,40,0,0,$src_info2[0],$src_info2[1]);
                imagedestroy($src_im2);
                $username = Db::table('tp_wy_users')->where('id',$userId)->value('xm');
                $name = "会员:".$username;
                $red = imagecolorallocate($dests, 255, 0, 0);
                ImageTTFText($dests, 20, 0, 160, 120, $red, ROOT_PATH."application/simkai.ttf", $name);

                $last_filename = ROOT_PATH."/public/code/" . $this->get_random().'.jpg';
                imagejpeg($dests,$last_filename);
                $wechat = new \app\common\weixin\Wechat($this->optionAuth);
                $arryimg = [
                    "media"=>'@'.$last_filename,
                ];
                $imgurl = $wechat->uploadMedia($arryimg,'image');
                $outcodeid = $imgurl["media_id"];
                Db::table('tp_wy_users')->where('id',$userId)->update(['outcodeid'=>$outcodeid]);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值