I'm currently looking for a js library that can encode text in qr codes. The only one I've been able to find so far seems broken, although other people claim to be using it. The sample page doesn't work. By playing a bit with it I managed to generate codes but they don't get decoded by the phone software.
我目前正在寻找一个可以用二维码编码文本的js库。到目前为止,我找到的唯一一个似乎已经坏掉了,尽管其他人声称正在使用它。示例页面不起作用。通过对它进行一点操作,我成功地生成了代码,但这些代码不会被手机软件解码。
Is there another library is js for this? Has anyone managed to get it to work?
这里还有js库吗?有人设法让它工作吗?
I'm not interested in a solution that pulls the code from an online service (kaywa, google etc.).
我对从在线服务(kaywa,谷歌等)获取代码的解决方案不感兴趣。
Update:
更新:
Well, you guys are right, that library does work. My problem was that I tried including it in a HTML5 Boilerplate page, and document.write doesn't seem to work in that. I modified the sample code anyway to make the browser draw in a canvas not a table and I got the order of the fillRect function backwards. Below is the corrected function call.
你们说得对,那个图书馆确实有用。我的问题是,我尝试将它包含在HTML5样板页面和文档中。写作在这一点上似乎行不通。我修改了示例代码,使浏览器在画布中绘制而不是表格,我得到了fillRect函数的顺序。下面是更正后的函数调用。
context.fillRect(c * UNIT_SIZE, r * UNIT_SIZE, UNIT_SIZE, UNIT_SIZE);
// it's column-row, not row-column; don't ask why :)
Since I don't get my image transposed anymore :), now the qr decodes fine. Thanks for the support.
由于我的图像不再被转置),现在二维码解码得很好。谢谢你的支持。
10 个解决方案
#1
23
Script you posted is WORKING, sample.html is not parsed as HTML.
你贴出的脚本正在工作,样本。html不被解析为html。
#2
26
I wrote a simple GPLv3 qr encoder in javascript that is local, uses HTML5 and is really fast as it is a port of an embedded C version I wrote for Atmel AVR processors.
我在javascript中编写了一个简单的GPLv3 qr二维码编码器,它是本地的,使用HTML5,速度非常快,因为它是我为Atmel AVR处理器编写的嵌入式C版本的端口。
http://code.google.com/p/jsqrencode/downloads/list
http://code.google.com/p/jsqrencode/downloads/list
There is a live version (which is saveable as a webapp on iOS devices) at http://zdez.org/qrenc3.html (save to home, opens in safari so you can copy the image or use airprint)
在http://zdez.org/qrenc3.html(保存到home,在safari中打开,以便您可以复制图像或使用airprint)有一个实时版本(可以在iOS设备上作为一个web应用程序保存)。
Here is the link to the downloadable source code.
这是可下载源代码的链接。
#3
18
There is a simple JavaScript library which I found sometime back called QRCode.js.
有一个简单的JavaScript库,我以前发现过它叫做QRCode.js。
QRCode.js is a cross-browser JavaScript library which allows you to generate QRCodes on the fly, on the client-side. QRCode.js makes use of HTMl5 Canvas and Tables to display the QRCode. The library itself has no dependencies whatsoever.
QRCode。js是一个跨浏览器的JavaScript库,允许您动态地在客户端生成qrcode。QRCode。js使用HTMl5 Canvas和表来显示QRCode。库本身没有任何依赖项。
To generate a QRCode, you just need to include the JavaScript library and then pass as parameters to the QRCode function, the text you want to encode as the QRCode, the width & height of the QRCode you want to display, as well as your specified foreground color and background color.
生成一个QRCode,你只需要包括JavaScript库,然后将作为参数传递给QRCode功能,你想要的文本编码QRCode,宽度和高度的QRCode你想显示,以及你的指定的前景色和背景色。
#4
8
I've found a working javascript-jquery based qrcode generator that you might be interested. Its opensource and it's really working. Here is the link: https://github.com/jeromeetienne/jquery-qrcode
我发现了一个基于javascript jquery的qrcode生成器,您可能会感兴趣。它是开源的,而且真的很好用。这里是链接:https://github.com/jeromeetienne/jquery-qrcode
The good thing about this one is that its light weight and it does not call any remote service or website.
它的优点是重量轻,不调用任何远程服务或网站。
#5
4
The QR code in the initial post only supports up to 271 bytes (version 10, Size = 57x57, EC level L).
最初发布的二维码最多支持271字节(版本10,大小= 57x57, EC level L)。
To make it support the full specs of QR code (version 40, 177x177, 2953 bytes), you have to add more values into its RS_BLOCK_TABLE.
要使它支持完整的二维码规范(版本40,177x177, 2953字节),您必须在它的RS_BLOCK_TABLE中添加更多的值。
See the remaining matrices (version 11-40) here: http://two.pairlist.net/pipermail/reportlab-users/2010-September/009707.html
参见下面的剩余矩阵(版本11-40):http://two.pairlist.net/pipermail/reportlab-users/2010-September/009707.html
#6
3
I am using the ShieldUI Lite QR Code, which can be found here:
我使用的是盾构QR码,可以在这里找到:
https://github.com/shieldui/shieldui-lite
https://github.com/shieldui/shieldui-lite
Contains all versions of the QR Code, all Error levels.
包含所有版本的二维码,所有错误级别。
#7
1
I couldn't find a javascript qr code generator.
我找不到javascript二维码生成器。
But you could Consider using Google's API:
但是你可以考虑使用谷歌的API:
http://code.google.com/apis/chart/docs/gallery/qr_codes.html http://togosoft.com/web/qrcode/qrcode.js
http://code.google.com/apis/chart/docs/gallery/qr_codes.html http://togosoft.com/web/qrcode/qrcode.js
Update: I just tried http://d-project.googlecode.com/svn/trunk/misc/qrcode/js/qrcode.js and seems fine to me. The only thing I did was increase the size and made it close the TDs properly, since self closing is not correct html. http://k3rmit.org/nopaste/759 I tested 3 different strings and used a App called QRReader on my iPhone to decode.
更新:我刚刚试过http://d-project.googlecode.com/svn/trunk/misc/qrcode/js/qrcode.js,我觉得挺好的。我所做的唯一的事情是增加大小并使它正确地关闭TDs,因为自关闭不是正确的html。http://k3rmit.org/nopaste/759我测试了3种不同的字符串,并在我的iPhone上使用名为QRReader的应用程序进行解码。
Update 2: With var qr = new QRCode(10, QRErrorCorrectLevel.L);
I was able to fit 271 chars in the QRCode however might not be the most reliable setting.
更新2:使用var qr =新QRCode(10, QRErrorCorrectLevel.L);我在QRCode中安装了271个chars,但是这可能不是最可靠的设置。
#8
1
npm has a few. I have no idea which ones are good.
npm有几个。我不知道哪一个好。
$ npm search qrcode
npm http GET https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1379059929305
npm http 200 https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1379059929305
NAME DESCRIPTION A
jsqrcode a node port of Lazar Laszlo's `jsqrcode` qr code decoder =
jsqrcode-lite Simplified version of Lazar Laszlo's `jsqrcode` for node. =
node-zxing ZXing Wrapper =
qr A small library to generate QR codes with libqrencode. =
qr-element qrcode dom element =
qr.js qrcode encoding in javascript =
qrcode QRCode / 2d Barcode api with both server side and client side s
qrcode-emitter Emits QR codes found in an image stream. =
qrcode-npm QRCode Generator for JavaScript =
qrcode-terminal QRCodes, in the terminal =
qrcode.js QR Code Detection / Decoding / Generation =
qread QRcode detector & decoder =
qruri NodeJS port of Kang Seonghoon's qr.js =
rescode Generate Codes (EAN13, QRCODE ..) =
zbar node-zbar is a NodeJS binding to the ZBar QR Code library.
#9
0
There is also the new kjua from the same author as the "old" jQuery.qrcode.
还有来自与“旧”jQuery.qrcode相同作者的新kjua。
#10
-1
If you can't find a native JavaScript implementation, you can always AJAX the image yourself from your server.
如果您无法找到一个本地JavaScript实现,那么您始终可以自己从服务器上AJAX映像。
http://www.swetake.com/qr/qr_cgi_e.html
http://www.swetake.com/qr/qr_cgi_e.html
#1
23
Script you posted is WORKING, sample.html is not parsed as HTML.
你贴出的脚本正在工作,样本。html不被解析为html。
#2
26
I wrote a simple GPLv3 qr encoder in javascript that is local, uses HTML5 and is really fast as it is a port of an embedded C version I wrote for Atmel AVR processors.
我在javascript中编写了一个简单的GPLv3 qr二维码编码器,它是本地的,使用HTML5,速度非常快,因为它是我为Atmel AVR处理器编写的嵌入式C版本的端口。
http://code.google.com/p/jsqrencode/downloads/list
http://code.google.com/p/jsqrencode/downloads/list
There is a live version (which is saveable as a webapp on iOS devices) at http://zdez.org/qrenc3.html (save to home, opens in safari so you can copy the image or use airprint)
在http://zdez.org/qrenc3.html(保存到home,在safari中打开,以便您可以复制图像或使用airprint)有一个实时版本(可以在iOS设备上作为一个web应用程序保存)。
Here is the link to the downloadable source code.
这是可下载源代码的链接。
#3
18
There is a simple JavaScript library which I found sometime back called QRCode.js.
有一个简单的JavaScript库,我以前发现过它叫做QRCode.js。
QRCode.js is a cross-browser JavaScript library which allows you to generate QRCodes on the fly, on the client-side. QRCode.js makes use of HTMl5 Canvas and Tables to display the QRCode. The library itself has no dependencies whatsoever.
QRCode。js是一个跨浏览器的JavaScript库,允许您动态地在客户端生成qrcode。QRCode。js使用HTMl5 Canvas和表来显示QRCode。库本身没有任何依赖项。
To generate a QRCode, you just need to include the JavaScript library and then pass as parameters to the QRCode function, the text you want to encode as the QRCode, the width & height of the QRCode you want to display, as well as your specified foreground color and background color.
生成一个QRCode,你只需要包括JavaScript库,然后将作为参数传递给QRCode功能,你想要的文本编码QRCode,宽度和高度的QRCode你想显示,以及你的指定的前景色和背景色。
#4
8
I've found a working javascript-jquery based qrcode generator that you might be interested. Its opensource and it's really working. Here is the link: https://github.com/jeromeetienne/jquery-qrcode
我发现了一个基于javascript jquery的qrcode生成器,您可能会感兴趣。它是开源的,而且真的很好用。这里是链接:https://github.com/jeromeetienne/jquery-qrcode
The good thing about this one is that its light weight and it does not call any remote service or website.
它的优点是重量轻,不调用任何远程服务或网站。
#5
4
The QR code in the initial post only supports up to 271 bytes (version 10, Size = 57x57, EC level L).
最初发布的二维码最多支持271字节(版本10,大小= 57x57, EC level L)。
To make it support the full specs of QR code (version 40, 177x177, 2953 bytes), you have to add more values into its RS_BLOCK_TABLE.
要使它支持完整的二维码规范(版本40,177x177, 2953字节),您必须在它的RS_BLOCK_TABLE中添加更多的值。
See the remaining matrices (version 11-40) here: http://two.pairlist.net/pipermail/reportlab-users/2010-September/009707.html
参见下面的剩余矩阵(版本11-40):http://two.pairlist.net/pipermail/reportlab-users/2010-September/009707.html
#6
3
I am using the ShieldUI Lite QR Code, which can be found here:
我使用的是盾构QR码,可以在这里找到:
https://github.com/shieldui/shieldui-lite
https://github.com/shieldui/shieldui-lite
Contains all versions of the QR Code, all Error levels.
包含所有版本的二维码,所有错误级别。
#7
1
I couldn't find a javascript qr code generator.
我找不到javascript二维码生成器。
But you could Consider using Google's API:
但是你可以考虑使用谷歌的API:
http://code.google.com/apis/chart/docs/gallery/qr_codes.html http://togosoft.com/web/qrcode/qrcode.js
http://code.google.com/apis/chart/docs/gallery/qr_codes.html http://togosoft.com/web/qrcode/qrcode.js
Update: I just tried http://d-project.googlecode.com/svn/trunk/misc/qrcode/js/qrcode.js and seems fine to me. The only thing I did was increase the size and made it close the TDs properly, since self closing is not correct html. http://k3rmit.org/nopaste/759 I tested 3 different strings and used a App called QRReader on my iPhone to decode.
更新:我刚刚试过http://d-project.googlecode.com/svn/trunk/misc/qrcode/js/qrcode.js,我觉得挺好的。我所做的唯一的事情是增加大小并使它正确地关闭TDs,因为自关闭不是正确的html。http://k3rmit.org/nopaste/759我测试了3种不同的字符串,并在我的iPhone上使用名为QRReader的应用程序进行解码。
Update 2: With var qr = new QRCode(10, QRErrorCorrectLevel.L);
I was able to fit 271 chars in the QRCode however might not be the most reliable setting.
更新2:使用var qr =新QRCode(10, QRErrorCorrectLevel.L);我在QRCode中安装了271个chars,但是这可能不是最可靠的设置。
#8
1
npm has a few. I have no idea which ones are good.
npm有几个。我不知道哪一个好。
$ npm search qrcode
npm http GET https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1379059929305
npm http 200 https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1379059929305
NAME DESCRIPTION A
jsqrcode a node port of Lazar Laszlo's `jsqrcode` qr code decoder =
jsqrcode-lite Simplified version of Lazar Laszlo's `jsqrcode` for node. =
node-zxing ZXing Wrapper =
qr A small library to generate QR codes with libqrencode. =
qr-element qrcode dom element =
qr.js qrcode encoding in javascript =
qrcode QRCode / 2d Barcode api with both server side and client side s
qrcode-emitter Emits QR codes found in an image stream. =
qrcode-npm QRCode Generator for JavaScript =
qrcode-terminal QRCodes, in the terminal =
qrcode.js QR Code Detection / Decoding / Generation =
qread QRcode detector & decoder =
qruri NodeJS port of Kang Seonghoon's qr.js =
rescode Generate Codes (EAN13, QRCODE ..) =
zbar node-zbar is a NodeJS binding to the ZBar QR Code library.
#9
0
There is also the new kjua from the same author as the "old" jQuery.qrcode.
还有来自与“旧”jQuery.qrcode相同作者的新kjua。
#10
-1
If you can't find a native JavaScript implementation, you can always AJAX the image yourself from your server.
如果您无法找到一个本地JavaScript实现,那么您始终可以自己从服务器上AJAX映像。
http://www.swetake.com/qr/qr_cgi_e.html
http://www.swetake.com/qr/qr_cgi_e.html