khanamiryan / php-qrcode-detector-decoder

This is a PHP library to detect and decode QR-codes. This is first and only QR code reader that works without extensions.
Apache License 2.0
1.38k stars 324 forks source link

PHP code works, but dumps a large PHP object #143

Open freebrowser1 opened 1 year ago

freebrowser1 commented 1 year ago

Install from: composer require khanamiryan/qrcode-detector-decoder. Created a file qr.php in the working folder where composer.json resides:

<?php
require __DIR__ . "/vendor/autoload.php";
use Zxing\QrReader;

//require_once(dirname(__FILE__). "src
if ($argc > 0) {
    $qrcode = new QrReader($argv[1]);
    var_dump( $qrcode);
//return decoded text from QR Code
} else {
    echo nl2br($argv[0] . " path_to_image\n");
}

Run from the working folder where composer.json resides: That results in 350000 lines of vomit starting and not the actual contents of the QR.

object(Zxing\QrReader)#3 (4) {
  ["bitmap":"Zxing\QrReader":private]=>
  object(Zxing\BinaryBitmap)#6 (2) {
    ["binarizer":"Zxing\BinaryBitmap":private]=>
    object(Zxing\Common\HybridBinarizer)#5 (5) {
      ["source":"Zxing\Binarizer":private]=>
      object(Zxing\GDLuminanceSource)#4 (8) {
        ["width":"Zxing\LuminanceSource":private]=>
        int(300)
        ["height":"Zxing\LuminanceSource":private]=>
        int(292)
        ["luminances"]=>
        array(87600) {
          [0]=>
          int(255)
          [1]=>
          int(255)
          [2]=>
          int(255)
===================================> 350000 (!) lines 
            int(254)
          }
          ["zero":"Zxing\Common\Reedsolomon\GenericGF":private]=>
          object(Zxing\Common\Reedsolomon\GenericGFPoly)#23 (2) {
            ["coefficients":"Zxing\Common\Reedsolomon\GenericGFPoly":private]=>
            array(1) {
              [0]=>
              int(0)
            }
            ["field":"Zxing\Common\Reedsolomon\GenericGFPoly":private]=>
            *RECURSION*
          }
          ["one":"Zxing\Common\Reedsolomon\GenericGF":private]=>
          object(Zxing\Common\Reedsolomon\GenericGFPoly)#24 (2) {
            ["coefficients":"Zxing\Common\Reedsolomon\GenericGFPoly":private]=>
            array(1) {
              [0]=>
              int(1)
            }
            ["field":"Zxing\Common\Reedsolomon\GenericGFPoly":private]=>
            *RECURSION*
          }
          ["primitive":"Zxing\Common\Reedsolomon\GenericGF":private]=>
          int(285)
          ["size":"Zxing\Common\Reedsolomon\GenericGF":private]=>
          int(256)
          ["generatorBase":"Zxing\Common\Reedsolomon\GenericGF":private]=>
          int(0)
        }
      }
    }
  }
  ["result":"Zxing\QrReader":private]=>
  NULL
  ["error":"Zxing\QrReader":private]=>
  NULL
}
ustpcz commented 8 months ago

Try var_dump( $qrcode->text());