1

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?

levent001
  • 174
  • 7

1 Answers1

1

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
Ron
  • 5,900
  • 2
  • 20
  • 30
  • one more input if you can help please? ` echo "
    ABC"; QRcode::png($text,false,'L',12,2); echo "
    "; ` Is it possible to render this QR code in some HTML DIV or TABLE for better formatting & alignment on the webpage? The above use of table code I'm trying to use is NOT working.
    – levent001 Apr 06 '23 at 14:52
  • You can base64 the output of this Rcode and load it inline like this: https://stackoverflow.com/questions/2807251/can-i-embed-a-png-image-into-an-html-page – Ron Apr 06 '23 at 15:00
  • 1
    or you can have a dedicated PHP file whih servers the image like: https://stackoverflow.com/a/48284751/2291328 – Ron Apr 06 '23 at 15:01