Git Product home page Git Product logo

jsqrcode's Introduction

JavaScript QRCode reader for HTML5 enabled browser.
2011 Lazar Laszlo  http://lazarsoft.info

Try it online: http://webqr.com

This is a port of ZXing qrcode scanner, http://code.google.com/p/zxing.

Usage:

Include the scripts in the following order:

<script type="text/javascript" src="grid.js"></script>
<script type="text/javascript" src="version.js"></script>
<script type="text/javascript" src="detector.js"></script>
<script type="text/javascript" src="formatinf.js"></script>
<script type="text/javascript" src="errorlevel.js"></script>
<script type="text/javascript" src="bitmat.js"></script>
<script type="text/javascript" src="datablock.js"></script>
<script type="text/javascript" src="bmparser.js"></script>
<script type="text/javascript" src="datamask.js"></script>
<script type="text/javascript" src="rsdecoder.js"></script>
<script type="text/javascript" src="gf256poly.js"></script>
<script type="text/javascript" src="gf256.js"></script>
<script type="text/javascript" src="decoder.js"></script>
<script type="text/javascript" src="qrcode.js"></script>
<script type="text/javascript" src="findpat.js"></script>
<script type="text/javascript" src="alignpat.js"></script>
<script type="text/javascript" src="databr.js"></script>

Set qrcode.callback to function "func(data)", where data will get the decoded information.

Decode image with: qrcode.decode(url or DataURL).
Decode from canvas with "qr-canvas" ID: qrcode.decode()

[new from 2014.01.09]
For webcam qrcode decoding (included in the test.html) you will need a browser with getUserMedia (WebRTC) capability.

jsqrcode's People

Contributors

laszlol77 avatar lazarsoft avatar tarun1793 avatar thulinma avatar yamatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsqrcode's Issues

Error scanning

Hi!
Well, I have a problem to scanning some images. when I edit the size of the image with error, it works, but then, the other qr images get the error.

Both images have the same size, but when I probe them here: http://webqr.com/ I get error with the first image.
Can anyone help me with that? this is happening with a lot of images, and I can't find why. thanks.

Image with error:
errorqr_341x353

Image without error:
ok_qr_341x353

Error decoding this QR code

When I try to decode the base64-encoded string:

"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAALCUlEQVR4nO2dz09TTxDAPatniqFepAU9IBhQE0qCFURJf2BiQluVM4lRT5YWU2irlpsi5SbU9A60KCHx5o9/wcR/wT/jfQ9+2ewu25033X2vFGaSSbrZ3ZnZ3Q+PvtedfefOnTvn+Km8QG3j8bjjVkqlkpEvrO7u7rqOzfa8WFYCgAAgAAgAAoAAOHEApNNpo4nxclJzuRyzXS6XjX2fKABsSTKZRA9UJ5hJxPaVNRaLafvzVwAIAKzItgqFgpE9nW0CgAAgAAgA5CK5XYRQKGTVtqyDg4NOIpFwEomEMzAwALY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Ab3vx4sWTA4DtKwBGbF8B5Ho/7wL4H4NkwT6FVMRCABAABAAB4AUAfX19VgGQ6w8ODloOzGsATObF1Ba/Fd9zAEwE+2sgJLIt278GuhUoORR7SJSb2HjFvjcQ8EUAEAAEAAHgl9qcCORAPe3PCwSA6RzyALTz24IUS/cAwL8zyMYhDSb9MYdFY2Px+qBIKRYCgAAgAM4sAP8BGaf1+Tuw7/QAAAAASUVORK5CYII="

I get a message that there was an error decoding the QR code. It should decode to http://bit.ly/HC4t2Y and does with another online decoder (zxing.org).

Position

Hello,

Thanks for writing this library, I am looking to experiment with it however it seems that it only decodes the QR Code and doesn't provide any of the other aspects like position.

Is it possible to do this?

Thanks

Tom

How to install?

Hi, i'm still learning web-programming, and i'm a bit lost on the readme...

I know i have to upload the src folder to my ftp-host and "Include the scripts in the following order:" in the webpage, but where it comes to the functions, i'm a bit lost.

Are there any example-sourcecode on a webpage that uses this?

All i want, is to get a QR-code reader on my webpage. (identical to http://webqr.com/ )

Thanks in advance.

QR Code not decoding in the sample

I tried the sample test.html include in the code base. It's need a "camcanvas.swf" file, so i created a swf (320 x 240) file after that i can see the camera preview, but i can't see it's decoding any QR Code, Can you help to me fix the issue. I need to support for browsers which are not support html5. please help.

1D Barcode support?

Hello,

while searching for resources I stumbled over your project. I'm developing a website to manage a stock of devices. To make it easier for the user to input some large numbers I want to integrate scanning(w/ the webcam) and decoding barcodes, the 1D ones not QR codes.

I'm developing the site using GWT 2.5 which has JSNI support. Do you think you will integrate support for decoding barcodes? Or is it already supported?

Thank you very much,
Marius M.

Problem with big images

Hi,
I have the following problem:

If I scan a big images the browser (Mobile Safari )will crash. Desktop Browser like the latest Firefox runs often into a Timeout exception.

Do you know any best practice to avoid this error? Otherwise, I will try to shrink the picture before it will be parsed by your QR Code scanner.

The code works pretty fine for smaller images.

Image info:
Image 1: 1,8MB, 3264_2448 // error
Image 2: 1,67 MB 2592_1935 // error

Thanks!

  • Tobi

Maintaining the library

Hi LazarSoft,

you seem not to be maintaining this library anymore. I would like to help you or maybe even take the lead of the library.

What do you think of that ?

Best

UPDATE:

I've started a new project at https://github.com/edi9999/jsqrcode
I've started by adding a first test. You can pull request it if you would like to add something to it.

Reverse QR code

I am trying to read a QR code which has, white QR code on Black background. Is this supported by the library? Or anyway can be make it compatible. I am trying this with image upload feature.

Support for PDF417 barcode

Hi,
because of jsqrcode is a 2D code scan-library do you have any plans including a pdf417 bar code reader? What is your opinion on this. I am expecting a suggestion from you.
Thanks.

iPhone camera's picture

Hi , we can not use the picture from iPhone camera.
Because the picture over 2 megapixels taken from iPhone Camera lose the orientation information and will not be decoded as QR code picture correctly.

From Sarafi Developer Library site:
"JPEG images can be up to 32 megapixels due to subsampling, which allows JPEG images to decode to a size that has one sixteenth the number of pixels. JPEG images larger than 2 megapixels are subsampled―that is, decoded to a reduced size. JPEG subsampling allows the user to view images from the latest digital cameras."

https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/CreatingContentforSafarioniPhone/CreatingContentforSafarioniPhone.html#//apple_ref/doc/uid/TP40006482-SW15

I think that this Apples's limits affect your QR decode function.
Because the picture will rotate and save , It will be able to be decode as QR code picture correctly.
I refer to "scan from image" ,NOT "scan from webcam" from http://www.webqr.com/.
This issue is not "getUserMedia API".
This issue is your QR Code decoder is not supported iPhone camera's spec.

Is this library maintained?

Hello,
I wonder if this library is maintained?

Is there an example on how to integrate it into my web app?

Thanks

Error when decoding a high density qrcode

When I try and use an image with any more characters then just a simple email or website, I keep getting a thrown exception that just says 'Error'

to reproduce, just go to the demo page: http://webqr.com/index.html

upload this qr:
download 3

It works fine for small qrcodes. When I upload the same graphic to http://zxing.org/w/decode it works.

Here is what is being passed into decode:

....scanQR = function(event) {

qrcode.callback = function(result) {... }

var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');

var img = new Image();
img.onload = function() {

if((img.width == 2448 && img.height == 3264) || (img.width == 3264 && img.height == 2448)) {
  canvas.width = 1024;
  canvas.height = 1365;
  context.drawImage(img, 0, 0, 1024, 1365);
} else if(img.width > 1024 || img.height > 1024) {
  canvas.width = img.width*0.15;
  canvas.height = img.height*0.15;
  context.drawImage(img, 0, 0, img.width*0.15, img.height*0.15);
} else {
  canvas.width = img.width;
  canvas.height = img.height;
  context.drawImage(img, 0, 0, img.width, img.height);
}
qrcode.decode(canvas.toDataURL('image/png'));

}

What am I doing wrong?

Decode many different qrcodes at the same time

Hi,

I would like to know if there's a way to decode many qrcodes at the same time.

My problem is the following: I have many images I would like to decode.

Howewer, if I use qrcode.callback to put in the callback, it will override it so only the callback for the last file will be called.

Can't decode QR code with some error in Format info pattern.

Hi,
this library seems can't decode the following QR code :
hello-world-final

It contains text 'HELLO WORLD' when scanned with my smartphone.
The problem probably is because the script can't recognize the format info pattern (it should be ECC level L with mask pattern 6).

Thanks in advance.

change camera (front/wear)

Is there a way to change camera used to scan?

When I opened on my phone, open the front camera, instead the rear camera.

can decode qrcode with long text

i use encryption for the text, and make it to QRcode but went i want scan it, it say "error decoding QR Code" i try it in your web online and i get the same result. but went i try it in zxing.org it work properly, can you fix it???
this i give you my qrcode example
44444

can't decode multiple times

i try to use jsqrcode on electron application with stream decode, but it just scan only one time, when i start the webcam again it say "qrcode.decode is not a function", i want to know how to use it for multiple times

Not work on Smart Devices.

the code not work in smart devices, don't ask for enable the camera is coming. just stay blank.
someone know hot to solve this?

Example page not working under Chrome since version 53

Since the new Chrome version 53 there is an error on your example site https://webqr.com/

Failed to load resource: The server responded with a status 404 (Not Found) [object%20MediaStream]

The src of the video tag is missing.

Anybody any idea what changed in chrome 53? I did not found any information within the chrome developer announcements according to this behaviour.

Since Chrome 52 everything was fine.

error in test.html

when i run test.html,it is tip error:Failed to load the image
how can i fix it?

Issue on iphone 4

Hi,
I've tried to use this library on iphone and it never succeed to analyse the qr code.

nothing bad is happening, and the library return a result, but the result is always the same: error decoding QR Code

I used the same code and same image on firefox on my pc and it work fine.

the code is the folowing :

        var file = e.currentTarget.files[0];//  this is my image
        var reader = new FileReader();

        reader.onload = function (e) {
            var dataURL = reader.result;
            qrcode.decode(dataURL);
        }

        qrcode.callback = function (data) {
            alert(data)
        }

        reader.readAsDataURL(file);

Thanks

Issue with mobile devices

Chrome for Android allows getUserMedia behind a flag now. Sadly the decoder seems to struggle on any mobile devices. Testing on webqr.com with a version 1 QR code on desktop and using getUserMedia is amazingly fast. However on a chrome tablet (tested on Nexus 7 & Asus Transformer) with version 1 QR you'll get an error: "Error getVersionForNumber". Then I tested version 3 QR code as well, and it will make it past the version check and then fail on: "ReedSolomonException Bad error location". And finally on version 4 QR code you'll get this error: "Error locator degree does not match number of roots"

Any ideas why this would be happening on mobile only?

Does not work on android tablet

I managed to implement the webqr.js in my project and since web works perfectly but when I try to scan from a tablet with android 4.4 does not work. The camera d ela tablet if it reads codes with other apps but it does not do with this implementation.
Is there a manual of options or can I modify to fix this?

Spelling/case error in decoder.js

Lines 70-74:

for (var i = 0; i < dataBlocks.Length; i++) {
...calculate total bytes
}

The "Length" member should be "length", otherwise "totalBytes" remains zero

d.ts?

I'm wondering... has anyone done a typescript d.ts file for this yet? If so I'd love to get a copy before I try this out. Unless I made a mistake, I couldn't find one on definitely typed...

Getting different image bits for Java vs. JS detector bitmap image matrix

After quite some debugging I think I have found a problem in the JS porting of the Java code. The Java code calls "new Detector(image.getBlackMatrix())" whereas the JS code calls (effecitvley) "new Detector(qrcode.grayScaleToBitmap(qrcode.grayscale())". This difference in code seems to cause the source data of the attached image to be incorrect to begin with - thus making the decoded result incorrect.
generated

Full ZXing Port ?

Are you planning to port the whole ZXing library ?

I both need to read barcodes and QR codes.

Thank you very much for providing such a killer feature to HTML5 projects.
(Can't wait for Mobile devices to implement UserMedia)

The right order to import the files

I tryed to use this api loading subscripts with the mentioned order but it didn't work. So I changed it and it worked. This is the order:

bitmat.js
grid.js
QRCode.js
findpat.js
detector.js
gf256poly.js
gf256.js
rsdecoder.js
decoder.js
version.js
formatinf.js
errorlevel.js
datablock.js
bmparser.js
datamask.js
alignpat.js
databr.js

error decoding QR Code - on iPhone 5 / iOS 7

Hi,

i've coded a really easy example for testing this script and it works fine on Mac/Chrome. But i got errors on iPhone/Chrome and iPhone/Safari. Here is my example:

<input type="file" accept="image/*" capture="camera" id="jsQR">
<div id="jsDebug"></div> <!-- because i haven't a console on my iphone -->

<script type="text/javascript">
var elDebug = $('#jsDebug'), /* this is a div container for debug content */
      elQR = $('#jsQR'); /* this is my input field */
elQR.on('change', function(e) {
    var filesObj = e.target.files; /* all files*/
    var fileObj  = filesObj[0]; /* my one and only file */
    elDebug.text(qrcode.decode(window.URL.createObjectURL(fileObj)));
});

/* callback */
qrcode.callback = qrCallback;
function qrCallback(data) {
    elDebug.text(data);
}       
</script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.