0.0.1 • Published 6 years ago

qrencode_mini v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

qrencode_mini

NPM version NPM Downloads

Node.js addon(N-API) QR-code generator based on libqrencode in C - a fast and compact QR Code encoding library. qrencode_mini module is for node.js server side usage. Implements not all feaures like its original lib has. Produces a buffer as output. That can be encoded to base64 string and added to the image src attribute in a html murkup.

Micro QR feature is some way experimental at the moment.

Dependencies

libpng must be installed.

Installation

npm install qrencode_mini

Usage

There is only one method.

const {qrencode} = require('qrencode_mini');

const options = {
background_color:'#76eec6', // hex string, optional, default: black
foreground_color:'#ff0000', // hex string, optional, default: white
level:"q", // string, optional, default: "l", LOW, 
//can be:"m", Medium
//       "q", Quartile
//       "h", High
dot_size: 6, // number, optional, default: 3
margin:2,    // number, optional, default: 4
micro:0,     // number, optional, default: 0 
// if a string to be encoded to the microQR? 0 means "NO", 1 = "YES"
version:4    // number, optional, default: 0 
// can be 0, 1, 2, 3, 4 //for microQR(if micro=1) must be equal to 3 or 4!!!!
}

let str="bitcoin:1BMXmqU3fZ8PVjPbxgeenEX93YYf74bjeB?amount50&label=John&message=Donation%20for%20project";
let buf=Buffer.from(str);

// a promise:

qrencode(buf, options).then(function(data){
console.log('data: ','data:image/png;base64,'+data.toString('base64'));
}).catch(function(err){console.log('err promise: ',err);
})

The version for microQR if micro = 1, must be specified to 3 or 4!

QR pics

  1. QR encoded "mama"

alt text

  1. microQR encoded "mama"

alt text

Perfomance

  • qrencode_mini is about x3 times faster than qr-node
  • qrencode_mini is about x300 times faster than qrcode-js
Iterations15100
qrencode_mini1.871ms5.181ms5.587ms
qr-node4.940ms41.030ms519.877ms
qrcode-js297.948ms1405.711ms9803.455ms