本文整理汇总了PHP中QRcode::png方法的典型用法代码示例。如果您正苦于以下问题:PHP QRcode::png方法的具体用法?PHP QRcode::png怎么用?PHP QRcode::png使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRcode
的用法示例。
在下文中一共展示了QRcode::png方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: genqrm
public static function genqrm($nombre, $ap, $am, $com, $filename)
{
$QR_TEMP_DIR = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'qrimg' . DIRECTORY_SEPARATOR;
$HTML_TEMP_DIR = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR;
$QR_WEB_DIR = "qrimg/";
$HTML_WEB_DIR = "html/";
include "phpqrcode.php";
if (!file_exists($QR_TEMP_DIR)) {
mkdir($QR_TEMP_DIR);
}
if (!file_exists($HTML_TEMP_DIR)) {
mkdir($HTML_TEMP_DIR);
}
$fileimg = $QR_TEMP_DIR . 'test.png';
$errorCorrectionLevel = 'Q';
$matrixPointSize = 6;
$filenameqr = $QR_WEB_DIR . $filename;
$filenamehtml = $HTML_WEB_DIR . $filename;
$fileimg = $filenameqr . '.png';
$filehtml = $filenamehtml . '.html';
$filehtmlqr = "192.168.1.5/demo/qr/" . $filehtml;
QRcode::png($filehtmlqr, $fileimg, $errorCorrectionLevel, $matrixPointSize, 2);
$mensaje = "\n\n <!DOCTYPE html>\n <html>\n <head>\n\n <title></title>\n </head>\n <body>\n\n Nombre: '{$nombre}' '{$ap}' '{$am}' <br><br>\n Comentario: '{$com}'\n\n </body>\n </html>\n\n ";
if ($archivo = fopen($filehtml, "a")) {
fwrite($archivo, $mensaje);
fclose($archivo);
}
echo '<img src="' . $QR_WEB_DIR . basename($fileimg) . '" />
<br>Datos guardados <a href="./index.php">Regresar</a><br>';
return $fileimg;
}
示例2: qrcode
public function qrcode()
{
import('Com.Wxpay.example.phpqrcode.phpqrcode', LIB_PATH, '.php');
$url = base64_decode($_GET["data"]);
\QRcode::png($url, false, QR_ECLEVEL_L, 9, 2);
exit;
}
示例3: createQR
public function createQR()
{
$info = collectinfo(__METHOD__, '', array());
$qr = M('qr');
//先取一个tempuid
$tmpuid = time() . rand(10, 99);
//加上随机数几乎是杜绝了统一时间一起产生的临时uid的可能性
$this->assign('tmpuid', $tmpuid);
$isscan = 0;
$openid = '';
$data = array('tmpuid' => $tmpuid, 'isscan' => $isscan, 'openid' => $openid);
$qr->data($data)->add();
$pic = './Public/img/qr/' . $tmpuid . '.png';
$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx682ad2cc417fe8b9&redirect_uri=http://www.evchar.cn/evcpc/oauth2_openid.php&response_type=code&scope=snsapi_base&state=" . $tmpuid . "&connect_redirect=1#wechat_redirect";
include "phpqrcode.php";
$c = $url;
$data = 'http://www.baidu.com';
// 纠错级别:L、M、Q、H
$level = 'L';
// 点的大小:1到10,用于手机端4就可以了
$size = 4;
// 下面注释了把二维码图片保存到本地的代码,如果要保存图片,用$fileName替换第二个参数false
//$path = "images/";
// 生成的文件名
//$fileName = $path.$size.'.png';
//只认从根目录去找的。。
QRcode::png($c, $pic, $level, $size);
$this->assign('pic', $pic);
return createarrok('ok', $pic, '', $info);
}
示例4: action_generate
public function action_generate()
{
$basePath = DOCROOT;
$embedLogo = true;
$logoFilePath = "{$basePath}uploads/tmp/qrcode/logo.png";
//二维码内容
$content = \Input::get('content', '');
//保存路径
$savePath = 'uploads/tmp/qrcode/';
//容错级别(L | M | Q | H)
$errLevel = 0;
//二维码尺寸(1 ~ 10)
$size = 10;
//空白边距
$margin = 2;
$name = time();
$qrFilePath = "{$basePath}{$savePath}{$name}.png";
\QRcode::png($content, $qrFilePath, $errLevel, $size, $margin);
$QRFile = imagecreatefromstring(file_get_contents($qrFilePath));
// 是否嵌入Logo
if ($embedLogo) {
$this->embedLogo($QRFile, $logoFilePath);
}
//保存为图片
//imagepng($QRFile, $qrFilePath);
//输出图片流
imagepng($QRFile);
}
示例5: init
public function init(){
//ofcourse we need rights to create temp dir
if (!file_exists($this->pngTempDir))
mkdir($this->pngTempDir);
if ($this->date != 'shopnc') {
// user data
if ($this->pngTempName != '') {
$filename = $this->pngTempDir.$this->pngTempName;
} else {
$filename = $this->pngTempDir.'test'.md5($this->date.'|'.$this->errorCorrectionLevel.'|'.$this->matrixPointSize).'.png';
}
QRcode::png($this->date, $filename, $this->errorCorrectionLevel, $this->matrixPointSize, 2);
} else {
//default data
QRcode::png('http://www.ejiao2o.com', $filename, $this->errorCorrectionLevel, $this->matrixPointSize, 2);
}
//display generated file
return basename($filename);
QRtools::timeBenchmark();
}
示例6: qrAction
public function qrAction()
{
$url = I('get.raw');
$url = base64_decode($url);
import_third('qrcode.phpqrcode');
\QRcode::png($url, false, QR_ECLEVEL_Q, 8);
}
示例7: execute
/**
* function description
*
* @param
* @return void
*/
public function execute($request)
{
$id = $request->id;
if (empty($id)) {
header("Location: " . SP_URL_HOME);
exit;
}
$data = Sp_Account_Attendee::getAttendeeBySn($id);
if (empty($data)) {
header("Location: " . SP_URL_HOME);
exit;
}
if ($request->type == 'code') {
include LIB_ROOT . 'third/phpqrcode/qrlib.php';
$errorCorrectionLevel = "L";
$matrixPointSize = "6";
QRcode::png($id, false, $errorCorrectionLevel, $matrixPointSize);
} else {
$active = Sp_Active_Active::getActiveById($data['activeId']);
if (empty($active)) {
$this->show404();
}
$data['sn'] = $this->formatSn($data['signId']);
$view = new Sp_View();
$view->assign('data', $data);
$view->assign('active', $active);
$view->display("attendee/code.html");
}
}
示例8: createImg
public static function createImg($content, $qrc_level = 'H', $qrc_size = 10, $logo = FALSE, $savePath = null)
{
include_once 'phpqrcode.php';
// if($savePath)
$QR = QRcode::png($content, $savePath, $qrc_level, $qrc_size, 2);
if ($logo !== FALSE) {
$QR = imagecreatefromstring(file_get_contents($savePath));
$logo = imagecreatefromstring(file_get_contents($logo));
$QR_width = imagesx($QR);
// 二维码图片宽度
$QR_height = imagesy($QR);
// 二维码图片高度
$logo_width = imagesx($logo);
// logo图片宽度
$logo_height = imagesy($logo);
// logo图片高度
$logo_qr_width = $QR_width / 5;
$scale = $logo_width / $logo_qr_width;
$logo_qr_height = $logo_height / $scale;
$from_width = ($QR_width - $logo_qr_width) / 2;
// 重新组合图片并调整大小
imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
}
return $QR;
}
示例9: logo
public function logo()
{
Vendor("phpqrcode.phpqrcode");
$QRcode = new \QRcode();
$path = "data/rq/";
$value = 'http://' . $_SERVER['HTTP_HOST'] . '/index.php?token=' . session('token');
$fileName = $path . session('token') . '_emall.png';
$QR_Logo = $path . session('token') . '_emall_Logo.png';
$errorCorrectionLevel = 'H';
$matrixPointSize = 10;
$QRcode->png($value, $fileName, $errorCorrectionLevel, $matrixPointSize, 2);
$logo = $path . 'weixinlogo.jpg';
$QR = $fileName;
if ($logo !== FALSE) {
$QR = imagecreatefromstring(file_get_contents($QR));
$logo = imagecreatefromstring(file_get_contents($logo));
$QR_width = imagesx($QR);
$QR_height = imagesy($QR);
$logo_width = imagesx($logo);
$logo_height = imagesy($logo);
$logo_qr_width = $QR_width / 5;
$scale = $logo_width / $logo_qr_width;
$logo_qr_height = $logo_height / $scale;
$from_width = ($QR_width - $logo_qr_width) / 2;
imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
}
imagepng($QR, $QR_Logo);
$this->assign('QR_Logo', $QR_Logo);
$this->display();
if (IS_AJAX) {
$response = $this->fetch();
$this->ajaxReturn(1, '', $response);
}
}
示例10: generateQRCode
/**
* 生成QRCode
*/
function generateQRCode($itemProduct)
{
//在这里要确保 products文件夹中apk名字 与 数据库名字一样
$qrCodeHref = DOMAIN . '/products' . '/' . $itemProduct['download'];
define('QR_NAME', 'itemQRCode.png');
QRcode::png($qrCodeHref, QR_NAME, 'L', 5.5);
}
示例11: getQRCode
function getQRCode($name, $secret)
{
global $tempDir;
$url = 'otpauth://totp/' . $name . '?secret=' . $secret . '';
QRcode::png($url, $tempDir . $secret . ".png", QR_ECLEVEL_L, 10);
return $tempDir . $secret . ".png";
}
示例12: fieldsFormDisplay
public function fieldsFormDisplay($rid = 0)
{
global $_W;
if (!empty($rid)) {
$reply = pdo_fetch("SELECT * FROM " . tablename('bm_qrsign_reply') . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid));
if (empty($reply['qrcode'])) {
if ($reply['qrtype'] == 0) {
$value = $_W['siteroot'] . 'app/' . $this->createmobileurl('sign', array('rid' => $rid));
$errorCorrectionLevel = 'H';
$matrixPointSize = '16';
$rand_file = rand() . '.png';
$att_target_file = 'qr-' . $rand_file;
$target_file = '../addons/bm_qrsign/tmppic/' . $att_target_file;
QRcode::png($value, $target_file, $errorCorrectionLevel, $matrixPointSize);
$reply['qrcode'] = $target_file;
} else {
$value = $_W['siteroot'] . 'app/' . $this->createmobileurl('pay', array('rid' => $rid));
$errorCorrectionLevel = 'H';
$matrixPointSize = '16';
$rand_file = rand() . '.png';
$att_target_file = 'qr-' . $rand_file;
$target_file = '../addons/bm_qrsign/tmppic/' . $att_target_file;
QRcode::png($value, $target_file, $errorCorrectionLevel, $matrixPointSize);
$reply['qrcode'] = $target_file;
}
}
}
load()->func('tpl');
include $this->template('form');
}
示例13: generate
public function generate($params = array())
{
if (isset($params['black']) && is_array($params['black']) && count($params['black']) == 3 && array_filter($params['black'], 'is_int') === $params['black']) {
QRimage::$black = $params['black'];
}
if (isset($params['white']) && is_array($params['white']) && count($params['white']) == 3 && array_filter($params['white'], 'is_int') === $params['white']) {
QRimage::$white = $params['white'];
}
$params['data'] = isset($params['data']) ? $params['data'] : 'QR Code Library';
if (isset($params['savename'])) {
$level = 'L';
if (isset($params['level']) && in_array($params['level'], array('L', 'M', 'Q', 'H'))) {
$level = $params['level'];
}
$size = 4;
if (isset($params['size'])) {
$size = min(max((int) $params['size'], 1), 10);
}
QRcode::png($params['data'], $params['savename'], $level, $size, 2);
return $params['savename'];
} else {
$level = 'L';
if (isset($params['level']) && in_array($params['level'], array('L', 'M', 'Q', 'H'))) {
$level = $params['level'];
}
$size = 4;
if (isset($params['size'])) {
$size = min(max((int) $params['size'], 1), 10);
}
QRcode::png($params['data'], NULL, $level, $size, 2);
}
}
示例14: saveAs
/**
* @param $type
* @param $text
* @param $file
* @param array $options
* @return bool
*/
public function saveAs($type, $text, $file, $options = array())
{
@unlink($file);
switch ($type) {
case $type == 'qr':
include_once __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "Resources" . DIRECTORY_SEPARATOR . "phpqrcode" . DIRECTORY_SEPARATOR . "qrlib.php";
$level = isset($options['level']) ? $options['level'] : QR_ECLEVEL_L;
$size = isset($options['size']) ? $options['size'] : 3;
$margin = isset($options['margin']) ? $options['margin'] : 4;
\QRcode::png($text, $file, $level, $size, $margin);
if (isset($options['useOverlay']) && $options['useOverlay']) {
$this->addOverlay($file, $size);
}
break;
case is_numeric($type):
$type = $this->types[$type];
default:
$barcodeOptions = array_merge(isset($options['barcodeOptions']) ? $options['barcodeOptions'] : array(), array('text' => $text));
$rendererOptions = isset($options['rendererOptions']) ? $options['rendererOptions'] : array();
$rendererOptions['width'] = isset($rendererOptions['width']) ? $rendererOptions['width'] : 2233;
$rendererOptions['height'] = isset($rendererOptions['height']) ? $rendererOptions['height'] : 649;
$image = new Image($imageResource = Barcode::factory($type, 'image', $barcodeOptions, $rendererOptions)->draw());
$image->save($file);
}
return true;
}
示例15: QRcode
public function QRcode()
{
include "./weimicms/Lib/ORG/phpqrcode.php";
$viewUrl = C("site_url") . U("Wap/Index/index", array("token" => $this->token));
$url = urldecode($viewUrl);
QRcode::png($url, false, 0, 8);
}