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

huangapple go评论61阅读模式
英文:

phpqrcode QR Code Resize when displayed directly in browser

问题

I am using this awesome feature of phpqrcode (https://sourceforge.net/projects/phpqrcode/) to dynamically generate 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);
?>

The last line of code QRcode::png($text); is where the magic happens. When provided only with a single argument ($text), it directly displays the QR code in the browser WITHOUT saving the PNG file into the webserver directory.

It comes in various options, like QRcode::png($text, $file_name, QR_ECLEVEL_L,10,3); allow for resizing the image size to a higher magnitude (argument value 10), and change the margin (argument value 3). However, these options require saving the PNG file of the QR code on the webserver directory (hence the argument $file_name needed), which obviously consumes a lot of webserver space.

I am looking for an option where using QRcode::png($text); (which DOES NOT save the PNG file on the webserver directory) enables me to change the size of the QR code image as displayed in the browser.

Anyone has any inputs to achieve that, please?

英文:

I am using this awesome feature of phpqrcode (https://sourceforge.net/projects/phpqrcode/) to dynamically generate QR Code:

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

The last line of code QRcode::png($text); is where the magic happens. When provided only with a single argument ($text), it directly displays the QR code in the browser WITHOUT saving the PNG file into the webserver directory.

It comes in various options, like QRcode::png($text, $file_name, QR_ECLEVEL_L,10,3); allow for resizing the image size to a higher magnitude (argument value 10), and change the margin (argument value 3).
However, these option require saving the PNG file of the QR code on the webserver directory (hence the argument $file_name needed), which obviously consumes a lot of webserver space.

I am looking for option where using QRcode::png($text); option (which DOES NOT save the PNG file on webserver directory), to enable me to change the size of the QR code image as displayed in the browser.

Anyone has any inputs to get that please?

答案1

得分: 1

Sure, here's the translated code part:

拥有:

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

意味着,如果通过增加第四个值来增加尺寸:

QRcode::png($text, false, 'L', 12, 2); // 12会使它变得更大,2是填充/也称为边距
英文:

Having:

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

means that if you increase the size by increasing the 4-th value:

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

huangapple
  • 本文由 发表于 2023年4月6日 22:30:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75950716.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定