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);//销毁图片
```


最终生成的效果图如下啦~~

猜你喜欢

转载自www.cnblogs.com/JGone/p/10002527.html