1. php生成二维码的几种方式
.altmi.com'; //生成的文件名$filename=$errorCorrectionLevel. '|'. $matrixPointSize. '.png'; //纠错级别:L、M、Q、H $errorCorrectionLevel='L'; //点的大小:1到10 $matrixPointSize=4;QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize,2); 官方给出的用例:<?php#include这两个文件之一:/*qrlib.phpforfullversion( formpackagepluscachedir) ORphpqrcode.phpformergedversion(onlyonefile, andquickermaskingconfigured)*/#两句话解释: #包含qrlib.php的话需要同其它文件放到一起:文件、文件夹。 #phpqrcode.php是合并后版本,只需要包含这个文件,但生成的图片速度慢而且不太准确 #以下给出两种用法: #创建一个二维码文件QRcode::png('codedatatext', #生成图片到浏览器QRcode::png('someothertext1234');//
2. php生成二维码的几种方式整理及使用实例
本文整理了一些php生成二维码的方式:1.google开放api;2.php类库PHP QR Code;3.libqrencode;4.QRcode Perl CGI & PHP scripts感兴趣的朋友可以参考下哈
1.google开放api
$urlToEncode="http://bbs.lewanchina.com";
generateQRfromGoogle($urlToEncode);
function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0')
{
$url = urlencode($url);
echo '<img src="http://chart.apis.google.com/chart?chs='.$widhtHeight.'x'.$widhtHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.'&chl='.$chl.'" alt="QR code" widhtHeight="'.$size.'" widhtHeight="'.$size.'"/>';
}
2.php类库PHP QR Code
PHP QR Code is open source (LGPL) library for generating QR Code,
2-dimensional barcode. Based on libqrencode C library,
provides API for creating QR Code barcode images (PNG, JPEG thanks to GD2).
Implemented purely in PHP, with no external dependencies (except GD2 if needed).
<?
include "./phpqrcode/phpqrcode.php";
$value="http://www.weste.net";
$errorCorrectionLevel = "L";
$matrixPointSize = "4";
QRcode::png($value, false, $errorCorrectionLevel, $matrixPointSize);
exit;
?>
3. php 如何形成二维码
使用PHPQRCode类库创建二维码
使用举例浏览器输出:
<?
include"phpqrcode/phpqrcode.php";
$errorCorrectionLevel="L";
$matrixPointSize="4";
QRcode::png($value,false,$errorCorrectionLevel,$matrixPointSize);
exit;
?>
文件输出二维码
include('phpqrcode/phpqrcode.php');
//二维码数据
//生成的文件名
$filename='1111.png';
//纠错级别:L、M、Q、H
$errorCorrectionLevel='L';
//点的大小:1到10
$matrixPointSize=4;
QRcode::png($data,$filename,$errorCorrectionLevel,$matrixPointSize,2);
生成中间带logo的二维码
<?php
include('phpqrcode/phpqrcode.php');
$errorCorrectionLevel='L';
$matrixPointSize=6;
QRcode::png($value,'xiangyang.png',$errorCorrectionLevel,$matrixPointSize,2);
echo"QRcodegenerated"."<br/>";
$logo='logo.png';
$QR='xiangyang.png';
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;
imageresampled($QR,$logo,$from_width,$from_width,0,0,$logo_qr_width,$logo_qr_height,$logo_width,$logo_height);
}
imagepng($QR,'xiangyanglog.png');
?>
自行下载phpqrcode.
4. 怎样生成彩色二维码
网上有好多二维码生成工具,例如草料二维码、Q兔二维码等,这些工具可以帮你在线生成二维码,并且可以自行设计二维码的样式,当然也可以设计成彩色的二维码。希望对你有帮助。
5. php使用qrcode库生成二维码后,向二维码中心位置添加小图标,小图标色彩变暗
最可能的原因就是 logo图片是带alpha通道的图片 也就是透明 可以用
imagealphablending 设置一下色彩混合模式
http://php.net/manual/zh/function.imagealphablending.php
6. 什么是彩色二维码,他和二维码有什么不一样啊
彩色二维码是特殊的二维码,具有普通黑白二维码的所有功能,又能呈现出彩色的外观。
两者最大的区别在于外观,彩色的外观更吸引人,但其前景色必须为较深的颜色,背景色必须是浅色。
两者承载的信息量是同样的,或许以后会有彩色独有的识别技术增大彩色信息存储量,但现阶段还是没有本质区别。