方位需要自己调整
public function erweima($device){
require_once 'mobile/example/phpqrcode/phpqrcode.php';
$device_sn = $device;
$urls = $this->Configm->urls();
$url = $urls."/Mobile/index.html?device_sn=".$device_sn;
$url = urldecode($url);
$qr_code_path = 'uploads/QRcodeDevice/'.date("Y-m-d").'/';
if (!file_exists($qr_code_path)) {
mkdir($qr_code_path);
}
/* 生成二维码 */
$qr_code_file = $qr_code_path.$device_sn.'.png';
QRcode::png($url, $qr_code_file, 'H', 6,6);//最后一个6是控制白边大小
$background = "mobile/font/back.png";
$logo = "mobile/font/logo.png";
$this->mark_photo($qr_code_file,$device_sn,$logo,$qr_code_file);
// $where = array('device_sn'=>$device);
$urls = $this->Configm->urls();
$arr['QRcode'] = $urls."/".$qr_code_file;
return $arr;
// $device_data = $this->Device_m->update($where,$arr);
}
//拼接图片,logo,文字
private function mark_photo($background,$text,$logo,$filename){
$back=imagecreatefrompng($background);
$color=imagecolorallocate($back,0,0,0);
$logo=imagecreatefrompng($logo);
$logo_w=imagesx($logo);
$logo_h=imagesy($logo);
$font="mobile/font/STYH.otf"; // 字体文件
//imagettftext只认utf8字体,所以用iconv转换
imagettftext($back, 21, 0, 40, 337, $color, $font, $text);//调二维码中字体位置
//执行合成调整位置
imagecopyresampled($back, $logo, 139,140, 0, 0, 65, 65, $logo_w, $logo_h);//调中间logo位置
imagejpeg($back,$filename);
imagedestroy($back);
imagedestroy($logo);
}