Search code examples
laravel-5qr-code

generate qr code with bacon/bacon-qr-code not working


I tried using your sample code on both an existing image and a non-existing image . Both case failed , and no image is generated on the latter.

first trial:

$renderer = new \BaconQrCode\Renderer\Image\Png();
$renderer->setHeight(256);
$renderer->setWidth(256);
$writer = new \BaconQrCode\Writer($renderer);
$writer->writeFile('Hello World!', 'qrcode.png');

i then thought i could just write string instead of writing into a file but when i echo i still don't get image

2nd trial :

`

         $renderer = new \BaconQrCode\Renderer\Image\Png();

        $renderer->setHeight(256);

        $renderer->setWidth(256);

        $writer = new \BaconQrCode\Writer($renderer);

        $str= $writer->writeString('Hello World!');
       header('Content-Type:image/png');
      echo $str;`

i get the code below

�PNG IHDR�?1IDATx����n�0A'����kP!��؝9��������~������' �4�&�@�Hi M� �4�&�@�Hi M� �4�&�@�Hi M� �4�&�@�Hi M� �4�&�@�Hi M� �4����x�^���3:|������u�+W�_u?O��9�p�'��4�&�@�Hi#�W�Z'^��?m=������|�Hi M� �4�6zpeպ�u�U�럾N?����<Hi M� �4�&Ҏ����@�'i M� �4�&�@�9�F�� ��<Hi M� �4�&Ҏ�L[/�v?w�~�?� @�Hi M� �4�6z0�|�?�>�~A�|���!M� �4�&�@�H�*���}��� M� �4�&�@�H����S_��������w'�� @�Hi M� �4�6b���u�����Ͽ�I�&�@�Hi M����~��u�Lx�<�^�����i M� �4�&�F�V�ǯz��ʴu��s�Us���Y�Q�0�&�@�Hi m�9�������U��w�|J� �4�&�@�H18�)�ᄒs��0 M� �4�&�@ڈ9���v���G�>E����̓M@�Hi M� ���\������<�������'i M� �4�&�@��9�����=��)� �'i M� �4�&�@ڑs�iv��?��?�'i M� �4�&�@�9�FO�{�j>P�3x�&�@�Hi M�98e�yչ����_�sw��>��4�&�@�Hi m����kv��OX��F�Hi M� �4��5y�v� M� �4�&�@�Hi M� �4�&�@�Hi M� �4�&�@�Hi M� �4�&�@�Hi M� �4�&�@�Hi M� ���mF�sE�}IEND�B

What's the problem ?

any help ?


Solution

  • I finally decided to use the package simpleqr-code . link here :https://www.simplesoftware.io/docs/simple-qrcode