QR Code With Pure JavaScript – A pure JavaScript QRCode encode and decode library. QR code encoder and decoder instruments which helps you shortly generate QR codes from given contents and decode QR codes from photographs.
How to make use of it –
Install the bundle.
# Yarn $ yarn add @nuintun/qrcode # NPM $ npm install @nuintun/qrcode --save
Import modules as per your wants.
// encoder import { Encoder, QRByte, QRKanji, ErrorCorrectionLevel } from '@nuintun/qrcode'; // decoder import { Decoder } from '@nuintun/qrcode';
Encoder
Generate a QR code from the content material you present.
const qrcode = new Encoder(); qrcode.write('你好世界n'); qrcode.write(new QRByte('hello worldn')); qrcode.write(new QRKanji('こんにちは世界')); qrcode.make(); console.log(qrcode.toDataURL());
Customize the encoder with the next strategies.
// set model qrcode.setVersion(number); // set the error correction degree // L, M, Q, H setErrorCorrectionLevel(degree); // set qrcode encoding hint setEncodingHint(hint);
More potential API strategies for the encoder.
// get matrix qrcode.getMatrix(); // qet matrix size qrcode.getMatrixSize(); // get model qrcode.getVersion(); // get error correction degree qrcode.ggetErrorCorrectionLevel(); // get qrcode encoding hint qrcode.getEncodingHint(); // add qrcode knowledge qrcode.write(QRByte | QRKanji | QRNumeric | QRAlphanumeric); // get byte with row and col qrcode.isDark(row: number, col: number); // generate qrcode.make(); // output base64 picture qrcode.toDataURL(moduleSize: number, margin: number)
Decoder:
Decode the QR code knowledge from a picture you present.
const qrcode = new Decoder(); qrcode .scan('qrcode.jpg') .then(result => ) .catch(error => );
Possible API strategies.
const qrcode = new Decoder(); // set choices qrcode.setOptions( inversionAttempts: 'dontInvert' ); // scan a picture qrcode.scan(src, promise); // decode a qrcode from picture knowledge decode(data: Uint8ClampedArray, width: number, height: number);
QR Code Generator Javascript, QR Code Javascript Github, Most Popular Plugins, QR Code Reader With JavaScript
Changelog:
v3.0.0 (08/10/2020)
- [Decoder]: Merge ECI chunk into QRByte chunk.
v3.0.0 (08/07/2020)
- Change error to straightforward error
v2.1.1 (06/16/2020)
- Add fallback locator level recenter
v2.0.1 (04/13/2020)
- Rename non-public property
- Rename strategies
v1.0.1 (11/19/2019)
- Fix “onlyInvert” inversionAttempts possibility
See Demo And Download
Official Website(nuintun): Click Here
This superior jQuery/javascript plugin is developed by nuintun. For extra Advanced Usages, please go to the official website.
Be First to Comment