1//Importing jimp module
2var Jimp = require("jimp");
3// Importing filesystem module
4var fs = require('fs')
5// Importing qrcode-reader module
6var qrCode = require('qrcode-reader');
7
8// Read the image and create a buffer
9// (Here image.png is our QR code)
10var buffer = fs.readFileSync(__dirname + '/image.png');
11
12// Parse the image using Jimp.read() method
13Jimp.read(buffer, function(err, image) {
14 if (err) {
15 console.error(err);
16 }
17 // Creating an instance of qrcode-reader module
18 let qrcode = new qrCode();
19 qrcode.callback = function(err, value) {
20 if (err) {
21 console.error(err);
22 }
23 // Printing the decrypted value
24 console.log(value.result);
25 };
26 // Decoding the QR code
27 qrcode.decode(image.bitmap);
28});
29