PHP Qrcode how to make it bigger

Asked

Viewed 192 times

1

I am generating a Qrcode through lib phpqrcode. I know you have the sizes L, H and others. But, are there ways to make the image bigger using other settings? Because, even on H is small for my need.

Here is my code

require_once "phpqrcode/qrlib.php";

  $code =  $qr;

  QRcode::png($code, "Imagem_QRCODE_H.png", QR_ECLEVEL_H);

  echo '<img src="Imagem_QRCODE_H.png"/>';
  • Wouldn’t that be your browser cache? Try this echo '<img src="Imagem_QRCODE_H.png?_=' . filemtime('Imagem_QRCODE_H.png') . '"/>';

1 answer

1


In the documentation there seems to be something about setting the zoom size of pixels. I imagine that will solve your problem.

    include('../lib/full/qrlib.php'); 
    include('config.php'); 

    // how to configure pixel "zoom" factor 

    $tempDir = EXAMPLE_TMP_SERVERPATH; 

    $codeContents = '123456DEMO'; 

    // generating 
    QRcode::png($codeContents, $tempDir.'007_1.png', QR_ECLEVEL_L, 1); 
    QRcode::png($codeContents, $tempDir.'007_2.png', QR_ECLEVEL_L, 2); 
    QRcode::png($codeContents, $tempDir.'007_3.png', QR_ECLEVEL_L, 3); 
    QRcode::png($codeContents, $tempDir.'007_4.png', QR_ECLEVEL_L, 4); 

    // displaying 
    echo '<img src="'.EXAMPLE_TMP_URLRELPATH.'007_1.png" />'; 
    echo '<img src="'.EXAMPLE_TMP_URLRELPATH.'007_2.png" />'; 
    echo '<img src="'.EXAMPLE_TMP_URLRELPATH.'007_3.png" />'; 
    echo '<img src="'.EXAMPLE_TMP_URLRELPATH.'007_4.png" />'; 

Exit:

inserir a descrição da imagem aqui

Documentation

Note: I did a test and realized that the image does not seem to be overwritten when a new one is generated with the same name, so for testing purposes it would be good to delete the previously generated image or simply generate a dynamic name with a hash for example:

$nameImg = md5(date('d-m-Y')).'.png';
QRcode::png($codeContents, $tempDir.$nameImg, QR_ECLEVEL_L, 5); 
echo '<img src="'.EXAMPLE_TMP_URLRELPATH.$nameImg'" />';
  • then.. I saw this documentation, but I put QR_ECLEVEL_H, 4 and it doesn’t change anything... it’s the same size.

  • 1

    I saw a configuration here now in the document you sent me that made the modification. Thanks @Darleifernandozilmer

Browser other questions tagged

You are not signed in. Login or sign up in order to post.