Qrcode.js identification and parsing of two-dimensional code images and generation of two-dimensional code images

Source: Internet
Author: User

QRCode only through the front-end can generate two-dimensional code and parsing two-dimensional code image,

First of all to introduce file Qrcode.js, as: http://static.runoob.com/download/qrcodejs-04f46c6.zip;

1. Identify local images:

Through the form of a file to get to the local picture, generate a temporary path to the picture, and then parse the two-dimensional code image;

The Qrcode.decode (IMG) method can parse the two-dimensional code image and return the parsed image to the text value via Qrcode.callback=function (IMG) {};

    Get preview picture path                var getobjecturl = function (file) {                 var url = null;                 if (window.createobjecturl!=undefined) {//basic                 URL = window.createobjecturl (file);                 } else if (window. url!=undefined) {//Mozilla (firefox)                 url = window. Url.createobjecturl (file);                  } else if (window.webkiturl!=undefined) {//WebKit or chrome                  URL = window.webkitURL.createObjectURL (file);                 }                  return URL;                 }                                Console.log (Getobjecturl (newfile[0]));//newfile[0] is a QR code image file uploaded via input files                qrcode.decode (Getobjecturl ( Newfile[0]));                Qrcode.callback = function (imgmsg) {                    console.log ("Imgmsg", imgmsg);                }

  

2, generate two-dimensional code:

var qrcode = new QRCode (document.getElementById ("QRCode"), {
WIDTH:100,
height:100
});

Qrcode.makecode (' 123123 ');

Generate two-dimensional code

Qrcode.js identification and parsing of two-dimensional code images and generation of two-dimensional code images

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.