英文:
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:
<?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 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,'L',12,2); // 12 makes it way bigger, 2 is the padding/they call it margin
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论