PHP下通过QRCode类库创建中间带网站LOGO的二维码


Posted in PHP onJuly 12, 2014

我们要生成二维码都需要借助一些类库来实现了,下面我介绍利用PHP QR Code生成二维码吧,生成方法很简单,下面我来介绍一下.

利用php类库PHP QR Code来实现,不需要装额外的php扩展,首先下载类库包,有时候地址打不开,地址:http://phpqrcode.sourceforge.net/

下载:
国内下载:https://3water.com/codes/189897.html
国外下载:http://sourceforge.net/projects/phpqrcode/

例子,使用PHP QR Code类库创建二维码。

1,浏览器输出:

<? 
include "phpqrcode/phpqrcode.php"; 
$value="https://3water.com"; 
$errorCorrectionLevel = "L"; 
$matrixPointSize = "4"; 
QRcode::png($value, false, $errorCorrectionLevel, $matrixPointSize); 
exit; 
?>

2,文件输出二维码

include('phpqrcode/phpqrcode.php'); 
// 二维码数据 
$data = 'https://3water.com'; 
// 生成的文件名 
$filename = '1111.png'; 
// 纠错级别:L、M、Q、H 
$errorCorrectionLevel = 'L'; 
// 点的大小:1到10 
$matrixPointSize = 4; 
QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);

3,生成中间带logo的二维码

<?php 
include('phpqrcode/phpqrcode.php'); 
$value='https://3water.com'; 
$errorCorrectionLevel = 'L'; 
$matrixPointSize = 6; 
QRcode::png($value, 'xiangyang.png', $errorCorrectionLevel, $matrixPointSize, 2); 
echo "QR code generated"."<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; 
imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height); 
} 
imagepng($QR,'xiangyanglog.png'); 
?>
PHP 相关文章推荐
php后台程序与Javascript的两种交互方式
Oct 25 PHP
setcookie中Cannot modify header information-headers already sent by错误的解决方法详解
May 08 PHP
php利用事务处理转账问题
Apr 22 PHP
纯PHP代码实现支付宝批量付款
Dec 24 PHP
PHP实现多关键字加亮功能
Oct 21 PHP
PHP memcache在微信公众平台的应用方法示例
Sep 13 PHP
PHP设计模式之适配器模式定义与用法详解
Apr 03 PHP
PHP二维索引数组的遍历实例分析【2种方式】
Jun 24 PHP
laravel框架数据库配置及操作数据库示例
Oct 10 PHP
php实现微信和支付宝支付的示例代码
Aug 11 PHP
PHP实现页面静态化深入讲解
Mar 04 PHP
利用ajax+php实现商品价格计算
Mar 31 PHP
PHP实现获取图片颜色值的方法
Jul 11 #PHP
PHP基于php_imagick_st-Q8.dll实现JPG合成GIF图片的方法
Jul 11 #PHP
php事务处理实例详解
Jul 11 #PHP
PHP实现显示照片exif信息的方法
Jul 11 #PHP
php中json_encode处理gbk与gb2312中文乱码问题的解决方法
Jul 10 #PHP
PHP5.3与5.5废弃与过期函数整理汇总
Jul 10 #PHP
ThinkPHP标签制作教程
Jul 10 #PHP
You might like
最省空间的计数器
2006/10/09 PHP
smarty+adodb+部分自定义类的php开发模式
2006/12/31 PHP
php GUID生成函数和类
2014/03/10 PHP
PHP图片等比缩放类SimpleImage使用方法和使用实例分享
2014/04/10 PHP
WordPress开发中自定义菜单的相关PHP函数使用简介
2016/01/05 PHP
XHTML-Strict 内允许出现的标签
2006/12/11 Javascript
JScript的条件编译
2007/05/29 Javascript
jQuery+CSS 实现的超Sexy下拉菜单
2010/01/17 Javascript
在javascript将NodeList作为Array数组处理的方法
2010/07/09 Javascript
javascript scrollTop正解使用方法
2013/11/14 Javascript
jQuery获取上传文件的名称的正则表达式
2015/05/21 Javascript
Javascript中的数据类型之旅
2015/10/18 Javascript
Jquery效果大全之制作电脑健康体检得分特效附源码下载
2015/11/02 Javascript
jQuery实现一个简单的验证码功能
2017/06/26 jQuery
详解利用jsx写vue组件的方法示例
2017/07/17 Javascript
基于Vue 服务端Cookies删除的问题
2018/09/21 Javascript
js删除对象/数组中null、undefined、空对象及空数组方法示例
2018/11/14 Javascript
python PIL模块与随机生成中文验证码
2016/02/27 Python
django 外键创建注意事项说明
2020/05/20 Python
编写python代码实现简单抽奖器
2020/10/20 Python
Python虚拟环境virtualenv创建及使用过程图解
2020/12/08 Python
Python爬虫进阶之爬取某视频并下载的实现
2020/12/08 Python
Python脚本调试工具安装过程
2021/01/11 Python
HTML5添加鼠标悬浮音响效果不使用FLASH
2014/04/23 HTML / CSS
英国布鲁姆精品店:Bloom Boutique
2018/03/01 全球购物
大学生求职中的自我评价
2013/10/01 职场文书
医学院校毕业生自荐信范文
2014/01/01 职场文书
小学生倡议书范文
2014/05/13 职场文书
2014年法制宣传日活动方案
2014/11/02 职场文书
开票员岗位职责
2015/02/12 职场文书
2015年青年志愿者工作总结
2015/05/20 职场文书
2016年春季运动会通讯稿
2015/11/25 职场文书
党员干部学习心得体会
2016/01/23 职场文书
Java 实战项目之家居购物商城系统详解流程
2021/11/11 Java/Android
Windows Server 2012配置DNS服务器的方法
2022/04/29 Servers
JS函数式编程实现XDM一
2022/06/16 Javascript