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. 什麼是彩色二維碼,他和二維碼有什麼不一樣啊
彩色二維碼是特殊的二維碼,具有普通黑白二維碼的所有功能,又能呈現出彩色的外觀。
兩者最大的區別在於外觀,彩色的外觀更吸引人,但其前景色必須為較深的顏色,背景色必須是淺色。
兩者承載的信息量是同樣的,或許以後會有彩色獨有的識別技術增大彩色信息存儲量,但現階段還是沒有本質區別。