phpqrcode QR Code直接在浏览器中显示时调整大小

pftdvrlh  于 2023-04-10  发布在  PHP
关注(0)|答案(1)|浏览(160)

我正在使用phpqrcode(https://sourceforge.net/projects/phpqrcode/)的这个强大功能来动态生成QR Code:

<?php
  
// Include the qrlib file
include './phpqrcode/qrlib.php';
  
// $text variable has data for QR 
$text = "Hello World!";
  
// QR Code generation using png()
// When this function has only the
// text parameter it directly
// outputs QR in the browser
QRcode::png($text);
?>

最后一行代码QRcode::png($text);是神奇的地方。当只提供一个参数($text)时,它直接在浏览器中显示QR码,而无需将PNG文件保存到Web服务器目录中。
它有各种选项,如QRcode::png($text, $file_name, QR_ECLEVEL_L,10,3);允许将图像大小调整到更高的大小(参数值10),并更改边距(参数值3)。然而,这些选项需要将QR码的PNG文件保存在Web服务器目录中(因此需要参数$file_name),这显然会消耗大量的Web服务器空间。
我正在寻找的选项,其中使用QRcode::png($text);选项(这不保存在Web服务器目录的PNG文件),使我能够改变在浏览器中显示的QR码图像的大小。
有没有人有任何意见,请得到?

nlejzf6q

nlejzf6q1#

具有:

//function png($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint=false){}

表示如果通过增加第4个值来增加大小:

QRcode::png($text,false,'L',12,2); // 12 makes it way bigger, 2 is the padding/they call it margin

相关问题