-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
31 lines (27 loc) · 811 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//Importing jimp module
var Jimp = require("jimp");
// Importing filesystem module
var fs = require('fs')
// Importing qrcode-reader module
var qrCode = require('qrcode-reader');
// Read the image and create a buffer
// (Here image.png is our QR code)
var buffer = fs.readFileSync(__dirname + '/qr.png');
console.log(typeof buffer)
// Parse the image using Jimp.read() method
Jimp.read(buffer, function (err, image) {
if (err) {
console.error(err);
}
// Creating an instance of qrcode-reader module
let qrcode = new qrCode();
qrcode.callback = function (err, value) {
if (err) {
console.error(err);
}
// Printing the decrypted value
console.log("1", value.result);
};
// Decoding the QR code
qrcode.decode(image.bitmap)
});