ushelp / EasyQRCodeJS

EasyQRCodeJS is a flexible QR code generator using JavaScript, supporting various drawing methods (Canvas, SVG, Table) and customization options. It's compatible with major frameworks and can be directly downloaded in the browser.
https://easyproject.cn/easyqrcode
MIT License
740 stars 155 forks source link

Library produces invalid qr code instead of error #93

Open hq6 opened 1 week ago

hq6 commented 1 week ago

Consider the following example:

<html>
<head>
<title>QR Code MWE</title>
<script type="text/javascript" src="easyQRCodeJS/easy.qrcode.min.js"></script>
</head>
<body>
<div id="qrcode" style="width:300px; height:300px; margin-top:15px;"></div>
<div id="debug" style="width:300px; height:300px; margin-top:15px;"></div>

<script type="text/javascript">

window.onload = function() {
    var qrcode = new QRCode(document.getElementById("qrcode"), {
    width : 300,
    height : 300,
    drawer: 'svg'
    });
    var size = 1000;
    var text = "".padEnd(size, "a")
    console.log(text)
    qrcode.makeCode(text);
}
</script>
</body>
</html>

Actual Behavior

Expected Behavior Either of the following behaviors seems reasonable:

alik2624 commented 1 week ago

qrcodemin I have tried the code in various sizes which are 100 by 100 300 by 300 600 by 600 In each size I was able to correctly get the content of qr code. What I see is the problem is related to the type of qr code or library error I have downloaded the easy.qrcode.min.js from the attached image github directory The problem can be from the faulty min.js file . Include this file directly in your code as <script type="text/javascript" src="easy.qrcode.min.js"></script>

I have tried Oneplus Official Camera Application and also third party application from play store for bar code scanners and almost 3 were tried and each gave accurate result for the qr code of each size.

hq6 commented 1 week ago

I literally downloaded the library by using the command:

wget https://raw.githubusercontent.com/ushelp/EasyQRCodeJS/refs/heads/master/dist/easy.qrcode.min.js

Also, I just realized my original example was incorrect because I was trying to binary search for the limit after which it started failing. The 600-character case works fine with 300 x 300. I've updated the example with a 1000-character version, which produces the QR code which I could not scan.

I've attached the generated QR code for reference: 1000As

This example is live at https://duke2011.com/qr/MWE.html

alik2624 commented 1 week ago

I have checked the qr code again and the application I am testing on to scan the qr code works without any issues The application I am using is https://play.google.com/store/apps/details?id=com.gamma.scan I even tried to increase the size of character to more than 1000. Everytime the scan was succesfull. I am sure your way of scanning is at fault here. Note: You character length can't be more than 1273 as it is the limit by this qr code library.

hq6 commented 1 week ago

This is quite curious, because I'm using exactly the same app on my Galaxy A14 phone and it fails to scan this QR code. Additionally, here is the output from zbarimg, for completeness:

zbarimg ~/Pictures/ScanMeTest.png
scanned 0 barcode symbols from 1 images in 0.16 seconds

WARNING: barcode data was not detected in some image(s)
Things to check:
  - is the barcode type supported? Currently supported symbologies are:
    . EAN/UPC (EAN-13, EAN-8, EAN-2, EAN-5, UPC-A, UPC-E, ISBN-10, ISBN-13)
    . DataBar, DataBar Expanded
    . Code 128
    . Code 93
    . Code 39
    . Codabar
    . Interleaved 2 of 5
    . QR code
    . SQ code
  - is the barcode large enough in the image?
  - is the barcode mostly in focus?
  - is there sufficient contrast/illumination?
  - If the symbol is split in several barcodes, are they combined in one image?
  - Did you enable the barcode type?
    some EAN/UPC codes are disabled by default. To enable all, use:
    $ zbarimg -S*.enable <files>
    Please also notice that some variants take precedence over others.
    Due to that, if you want, for example, ISBN-10, you should do:
    $ zbarimg -Sisbn10.enable <files>

I'll also add that when I create a qrcode from the same text with any of the following tools, both my phone and zbarimg are able to scan it without issue:

However, if you are not able to reproduce the issue, then I'm not sure leaving it open is useful, so I'll close this issue. Perhaps if someone else runs across this, they can reopen this issue.

hq6 commented 1 week ago

Additionally, I tried a couple of online QR Code scanners with the QR code above and they were also unable to parse it:

Generated_By_QREncode

hq6 commented 1 week ago

Reopening since the websites might be able to help you reproduce the issue.