Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library produces invalid qr code instead of error #93

Open
hq6 opened this issue Nov 9, 2024 · 6 comments
Open

Library produces invalid qr code instead of error #93

hq6 opened this issue Nov 9, 2024 · 6 comments

Comments

@hq6
Copy link

hq6 commented Nov 9, 2024

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

  • When I run this example, it produces a QR code that is not recognized by any QR code scanner I've tried (zbarimg, my Samsung phone).
  • However, if I increase the width and height to 600, then it produces a correct QR code that I can scan.

Expected Behavior
Either of the following behaviors seems reasonable:

  • The library throws an error if it cannot produce a valid QR code for the given dimensions and size.
  • The library generates a correct QR code at the given 300 x 300 size.
@hq6 hq6 changed the title svg does not scale down correctly and does not produce error Library produces invalid qr code instead of error Nov 9, 2024
@alik2624
Copy link

alik2624 commented Nov 9, 2024

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
Copy link
Author

hq6 commented Nov 9, 2024

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
Copy link

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
Copy link
Author

hq6 commented Nov 10, 2024

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 hq6 closed this as completed Nov 10, 2024
@hq6
Copy link
Author

hq6 commented Nov 10, 2024

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

On the other hand, both of these websites are able to parse the following QR code, generated by qrencode:

Generated_By_QREncode

@hq6
Copy link
Author

hq6 commented Nov 10, 2024

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

@hq6 hq6 reopened this Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants