phpqrcode QR Code Resize when displayed directly in browser

I am using this awesome feature of phpqrcode ( to dynamically generate QR Code:

// 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

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?

>Solution :


//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

Leave a Reply