时间:2021-07-01 10:21:17 帮助过:15人阅读
function Build_SAEQrcode($filename = '', $text='', $size='8', $logo = false){
$return = false;
$level='H';
$padding=1;
$path = 'saestor://uploads/direwm/';
$QR = $path.$filename.".png";
vendor("phpqrcode.qrlib");
QRcode::png($text,$QR, $level, $size,$padding);
if($logo === true){
$QR = imagecreatefromstring(file_get_contents($QR));
$logocontext = imagecreatefromstring(file_get_contents('./uploads/logo.png'));
$QR_width = imagesx($QR);
$QR_height = imagesy($QR);
$logo_width = imagesx($logocontext);
$logo_height = imagesy($logocontext);
$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;
$return = imagecopyresampled($QR, $logocontext, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
header("Content-Type:image/png");
imagepng($QR, $path.$filename.".png");
}else $return = true;
imagedestroy($QR);
return $return;
}