png($yqcode, $temp, $errorCorrectionLevel, $matrixPointSize, 2); $image = \think\Image::open($temp); // $logowidth = round($image->width()/4); // $orgId = cur_org_id(); if($orgId == 17){ $logo = './hb.png'; }else{ $logo = './logo.png'; } $imagelogo = \think\Image::open($logo); $imagelogo->thumb($logowidth,$logowidth,\think\Image::THUMB_SCALING)->save($templogo); $image->water($templogo,\think\Image::WATER_CENTER)->save($temp2); $QRBuffer = imagecreatefromstring(file_get_contents($temp2)); @unlink($temp); @unlink($temp2); @unlink($templogo); //输出图片 ob_clean(); header('Content-type: image/png'); imagepng($QRBuffer); exit(); } public function wj_code(){ //问卷调查 $get = $_GET; $r = ''; $i = 1; foreach ($get as $k=>$v){ if(count($get)!=$i && $k!='url'){ $r.=$k.'='.$v.'&'; }else{ if($k!='url'){ $r.=$k.'='.$v; }else{ if(count($get)==$i){ $r.=$v; }else{ $r.=$v.'&'; } } } $i++; } // $value = $_GET['url'];//二维码内容 $yqcode =$r;//二维码内容 if (empty($yqcode)) { $this->error('URL不能为空'); } //生成二维码图片 $object = new \phpqrcode\QRcode(); $level=3; $size=9; $errorCorrectionLevel =intval($level) ;//容错级别 $matrixPointSize = intval($size);//生成图片大小 $temp = './uploads/temp/'.md5($yqcode).'.png'; $temp2 = './uploads/temp/'.md5($yqcode).'_2.png'; $templogo = './uploads/temp/'.md5($yqcode).'_logo.png'; $object->png($yqcode, $temp, $errorCorrectionLevel, $matrixPointSize, 2); $image = \think\Image::open($temp); // $logowidth = round($image->width()/4); // $orgId = cur_org_id(); if($orgId == 17){ $logo = './hb.png'; }else{ $logo = './logo.png'; } $imagelogo = \think\Image::open($logo); $imagelogo->thumb($logowidth,$logowidth,\think\Image::THUMB_SCALING)->save($templogo); $image->water($templogo,\think\Image::WATER_CENTER)->save($temp2); $QRBuffer = imagecreatefromstring(file_get_contents($temp2)); @unlink($temp); @unlink($temp2); @unlink($templogo); //输出图片 ob_clean(); header('Content-type: image/png'); imagepng($QRBuffer); exit(); } }