A Node.js Addon of the quirc library (QR decoder library - https://github.com/dlbeer/quirc).
First, You need libpng (and its header files) installed. Then, simply
% npm install node-quirc
node-quirc aim to be simple to use, the module exposes a decode()
function
and a constants
object.
img
must be a Buffer
of a PNG encoded image file. Currently only PNG is
supported, but JPEG support is planned (see #2).
callback
is a "classic" Node.js callback function, taking an error as first
argument and the result as second argument. Because the provided image file may
contains several QR Code, the result is always an array on success.
const fs = require("fs");
const quirc = require("node-quirc");
quirc.decode(fs.readFileSync("Hello+World.png"), (err, codes) => {
if (err) {
console.error(`decode failed: ${err.message}`);
} else {
console.dir(codes);
}
});
/* output:
[ { version: 1,
ecc_level: 'L',
mask: 0,
mode: 'BYTE',
data: Buffer [ 72, 101, 108, 108, 111 ] },
{ version: 1,
ecc_level: 'L',
mask: 7,
mode: 'BYTE',
data: Buffer [ 87, 111, 114, 108, 100 ] } ]
*/
see https://github.com/kAworu/node-quirc/blob/master/index.js#L9
Clone the repo and then simply
% npm install && npm test
MIT, see LICENSE.