Online QR Code Reader With Pure JavaScript – qrcode-parser

Category: Javascript | April 13, 2018
Author: sinchang
Views Total: 268
Official Page: Go to website
Last Update: April 13, 2018
License: MIT

Preview:

Online QR Code Reader With Pure JavaScript – qrcode-parser

Description:

qrcode-parser is a JavaScript library to parse and read information from QR codes you provide in File objects or image urls.

Dependencies:

  • jsQR: QR code reading library.
  • UPNG.js: PNG (APNG) decoder and encoder.

How to use it:

Install the qrcode-parser:

# Yarn
$ yarn add qrcode-parser

# NPM
$ npm install qrcode-parser --save

The example app.

import qrcodeParser from src'

const imageUrl = 'qrcode.png'

qrcodeParser(imageUrl).then(res => {
  document.getElementById('content').innerText = res.data
})

const fileElement = document.getElementById('file')
fileElement.addEventListener('change', () => {
  const file = fileElement.files[0]
  qrcodeParser(file).then(res => {
    document.getElementById('content').innerText = res.data
  })
}, false)

Leave a Reply