您当前的位置: 首页 > 网站编程 > PHP教程 > 利用phpqrcode生成二维码实例代码

利用phpqrcode生成二维码实例代码

作者:不详 来源:网络 发布时间: 2014-08-14 21:28 点击:
QR码详细原理可以参考QR维基百科,中文版介绍比较少,英文版介绍很全面,推荐看英文版的。 Description 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 Co

利用phpqrcode生成二维码实例代码

  QR码详细原理可以参考QR维基百科,中文版介绍比较少,英文版介绍很全面,推荐看英文版的。

  Description

  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.

  Features

  •Supports QR Code versions (size) 1-40

  •Numeric, Alphanumeric, 8-bit and Kanji encoding.

  •Implemented purely in PHP, no external dependencies except GD2

  •Exports to PNG, JPEG images, also exports as bit-table

  •TCPDF 2-D barcode API integration

  •Easy to configure

  •Data cache for calculation speed-up

  •Debug data dump, error logging, time benchmarking

  •Provided merge tool helps deploy library as a one file

  •new! API documentation

  •new! Over 30 detailed examples

  •100% Open Source, LGPL Licensed

  Demo

  项目地址:http://sourceforge.net/projects/phpqrcode/

  Generate fixed size images

  * phpqrcode本身未提供固定大小二维码的设置,请参考 http://sourceforge.net/p/phpqrcode/discussion/1111884/thread/f739531a/

  

  

  

  

  

  

  

  

  

  

  
代码如下


  --- original/phpqrcode/qrimage.php      2010-08-18 07:06:24.000000000 -0700

  +++ qrimage.php 2012-07-13 00:51:57.000000000 -0700

  @@ -86,10 +86,15 @@

                  }

              }

  -           $target_image =ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint);

  -           ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);

  +

  +           $targetW = (defined('IMAGE_WIDTH') ? IMAGE_WIDTH : $imgW * $pixelPerPoint );

  +           $targetH = (defined('IMAGE_HEIGHT') ? IMAGE_HEIGHT : $imgH * $pixelPerPoint );

  +

  +           $target_image =ImageCreate($targetW, $targetH);

  +

  +           ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $targetW, $targetH, $imgW, $imgH);

              ImageDestroy($base_image);

              return $target_image;

          }

  -   }

  No newline at end of file

  +   }

  用法,设置生成的二维码宽高为 500px

  define('IMAGE_WIDTH', 500);

  define('IMAGE_HEIGHT', 500);

  QRcode::png('http://www.111cn.net/)');

  
分享到:
本文"利用phpqrcode生成二维码实例代码"由远航站长收集整理而来,仅供大家学习与参考使用。更多网站制作教程尽在远航站长站。
顶一下
(0)
0%
踩一下
(0)
0%
[点击 次] [返回上一页] [打印]
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
关于本站 - 联系我们 - 网站声明 - 友情连接- 网站地图 - 站点地图 - 返回顶部
Copyright © 2007-2013 www.yhzhan.com(远航站长). All Rights Reserved .
远航站长:为中小站长提供最佳的学习与交流平台,提供网页制作与网站编程等各类网站制作教程.
官方QQ:445490277 网站群:26680406 网站备案号:豫ICP备07500620号-4