LazarSoft / jsqrcode

Javascript QRCode scanner
http://www.webqr.com
Apache License 2.0
3.96k stars 1.16k forks source link

Error when decoding a high density qrcode #38

Open lrossy opened 9 years ago

lrossy commented 9 years ago

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?

dmborque314 commented 9 years ago

Looks like I have the same problem here. I can decode QR codes as long as the string encoded is not longer than 300-some characters. For longer strings I get an error (on my implementation) and an "error decoding QR code" in the web.

For example, working QR of a string 300 characters long: qrcode300

and the qr of a sightly longer string: qrcode311

JMLX42 commented 8 years ago

Hi,

did you find a solution for this ?