48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: bahamut
|
|
* Date: 2018/7/30
|
|
* Time: 9:55
|
|
*/
|
|
|
|
require_once __DIR__ . '/pay/phpqrcode/merged/phpqrcode.php';
|
|
|
|
|
|
$url = $_REQUEST['data'];
|
|
|
|
$local_path = __DIR__ . '/pay';
|
|
$short_name = '/qrcodeimg/' . date('YmdHis') . '.png';
|
|
$logo_name = $local_path . '/img/qr_logo.png';
|
|
$long_name = $local_path . $short_name;
|
|
QRcode::png($url, $long_name, QR_ECLEVEL_L, 8, 2);
|
|
|
|
/// 合并二维码和logo图片
|
|
$img = imagecreatefromstring(file_get_contents($long_name));
|
|
$logo = imagecreatefromstring(file_get_contents($logo_name));
|
|
|
|
if ($img && $logo) {
|
|
$img_width = imagesx($img); /// 二维码图片宽度
|
|
$img_height = imagesy($img); /// 二维码图片高度
|
|
$logo_width = imagesx($logo); /// logo图片宽度
|
|
$logo_height = imagesy($logo); /// logo图片高度
|
|
$logo_qr_width = $img_width / 6;
|
|
$scale = $logo_width / $logo_qr_width;
|
|
$logo_qr_height = $logo_height / $scale;
|
|
$from_width = ($img_width - $logo_qr_width) / 2;
|
|
|
|
/// 重新组合图片并调整大小
|
|
imagecopyresampled($img, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
|
|
|
|
/// 输出图片
|
|
header('Content-type: image/png');
|
|
imagepng($img);
|
|
|
|
imagedestroy($logo);
|
|
imagedestroy($img);
|
|
}
|
|
|
|
///$img_link = dirname(GetLocaleUrl()) . $short_name;
|
|
///echo "<center><a href=\"{$img_link}\"><img src=\"{$img_link}\"></a><br /><font size=\"20\">在线支付</font></center>";
|
|
unlink($long_name);
|
|
exit; |