Browse Source

二维码带图片

undefined
v-Brocloni 4 years ago
parent
commit
59920633fd
2 changed files with 12 additions and 1 deletions
  1. +12
    -1
      addons/unishop/controller/Order.php
  2. BIN
      addons/unishop/library/phpqrcode/logo.png

+ 12
- 1
addons/unishop/controller/Order.php View File

@@ -706,7 +706,18 @@ class Order extends Base
//生成二维码图片
\QRcode::png($value, $QRFile, $errorCorrectionLevel, $matrixPointSize, 2);
$QR = imagecreatefromstring(file_get_contents($QRFile));

//二维码
$logoUrl = imagecreatefromstring(file_get_contents(ROOT_PATH . '/addons/unishop/library/phpqrcode/logo.png'));
$QR_width = imagesx($QR);//二维码图片宽度
$logo_width = imagesx($logoUrl);//logo图片宽度
$logo_height = imagesy($logoUrl);//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, $logoUrl, $from_width, $from_width, 0, 0, $logo_qr_width,
$logo_qr_height, $logo_width, $logo_height);
//输出图片
Header("Content-type: image/png");
ImagePng($QR);


BIN
addons/unishop/library/phpqrcode/logo.png View File

Before After
Width: 80  |  Height: 79  |  Size: 7.2 KiB

Loading…
Cancel
Save