php二维码/26行代码制作php二维码phpqrcode加grafika水印

**

欢迎大家加入讨论 q裙827880170

**

用到的插件有phpqrcode(二维码的生成库,自行百度)
grafika(非常好用的图片处理库,自行百度)

require_once "phpqrcode/phpqrcode.php";
require_once 'grafika/src/autoloader.php';
$editor = \Grafika\Grafika::createEditor(); //实例化
$object = new \QRcode();
$logo_path = 'images/qr_logo_s.png';//logo地址
$diban_path = 'images/qr_diban_s.png';//背景图
$qr_tmp_path = 'images/tmp_qr.png';//二维码生成的临时二维码
$qr_tmp_path2 = 'images/tmp_qr2.png';//二维码生成的临时二维码
$qr_url = 'images/qr.png';//最终生成二维码
$value = 'http://233.1231231231231231231231231231231.222'; //二维码内容,如果是网址最好加上http://||https://(V
vx扫描可以直接出网址)
$water = 'No.123456';
$errorCorrectionLevel = 'H';//容错级别
$matrixPointSize = 3.7;//生成图片大小
$matrixMarginSize = 2;//边距大小
$object::png($value,$qr_tmp_path, $errorCorrectionLevel, $matrixPointSize, $matrixMarginSize);
$editor->open($image1 , $qr_tmp_path );
$editor->open( $image2 , $logo_path);
$editor->blend ( $image1, $image2 , 'normal', 1, 'top-left',72,71);//位置需要根据自己的项目自行调整
$editor->save($image1,$qr_tmp_path2);
$editor->open($image3 , $diban_path);
$editor->open($image4 ,$qr_tmp_path2 );
$editor->blend ( $image3, $image4 , 'normal', 1, 'top-left',32.5,54);//位置需要根据自己的项目自行调整
$editor->text($image3 ,$water,11,89.5,260,new \Grafika\Color("#ffffff"));//加入水印
$editor->save($image3,$qr_url);
unlink($qr_tmp_path);//销毁图片
unlink($qr_tmp_path2);//销毁图片

最终生成的效果图如下啦~~
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值