javascript-barcode-reader
TypeScript icon, indicating that this package has built-in type declarations

0.6.9 • Public • Published

Javascript-Barcode-Reader

Simple & Fast Barcode decoder for Browsers and Node.js capapable of reading Code128 (UCC/EAN-128), Code93, Code39, Standard/Industrial 2 of 5, Interleaved 2 of 5, Codabar and EAN-13 barcodes.

Build Status codebeat badge codecov All Contributors Rate on Openbase

NPM

Try now

https://codesandbox.io/s/javascript-barcode-reader-liium

Available decoders

  • EAN-13
  • EAN-8
  • Code-39
  • Code-93
  • Code-2of5
    • standard
    • Interleaved
  • Codabar
  • Code-128 (UCC/EAN-128)

How to use

Install

Recommended way to install is by using package manager (npm, yarn etc):

npm i javascript-barcode-reader

or use cdn:

<script src="//unpkg.com/javascript-barcode-reader"></script>

or download manually:

javascript-barcode-reader

Node.js

import javascriptBarcodeReader from 'javascript-barcode-reader'

javascriptBarcodeReader({
  /* Image file Path || {data: Uint8ClampedArray, width, height} || HTML5 Canvas ImageData */
  image: source,
  barcode: 'code-2of5',
  // barcodeType: 'industrial',
  options: {    
    // useAdaptiveThreshold: true // for images with sahded portions
    // singlePass: true
  }
})
  .then(code => {
    console.log(code)
  })
  .catch(err => {
    console.log(err)
  })

Browser

javascriptBarcodeReader will be available as global in Browsers.

javascriptBarcodeReader({
  /* Image ID || HTML5 Image || HTML5 Canvas || HTML5 Canvas ImageData || Image URL */
  image: source,
  barcode: 'code-2of5',
  // barcodeType: 'industrial',
  options: {
    // useAdaptiveThreshold: true // for images with sahded portions
    // singlePass: true
  }
})
  .then(code => {
    console.log(code)
  })
  .catch(err => {
    console.log(err)
  })

Note

  • This script does not implement logic to locate/rotate barcode in the given image.
  • Make sure the barcode image is the only thing in the image. Otherwise this script will most probably fail.

Contributing

  • Each decoder is defined in src directory as a module.
  • Tests are defined in the tests directory using Jest.

Contributors

Thanks goes to these wonderful people (emoji key):

Cristian Nitescu
Cristian Nitescu

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.6.91,433latest

Version History

VersionDownloads (Last 7 Days)Published
0.6.91,433
0.6.891
0.6.73
0.6.63
0.6.54
0.6.43
0.6.33
0.6.24
0.6.13
0.6.03
0.5.47
0.5.32
0.5.02
0.4.249
0.4.203
0.4.182
0.4.173
0.4.162
0.4.153
0.4.143
0.4.123
0.4.113
0.4.102
0.4.92
0.4.82
0.4.72
0.4.62
0.4.22
0.4.12
0.4.02
0.3.120
0.3.03
0.2.84
0.2.72
0.2.62
0.2.52
0.2.42
0.2.32
0.2.22
0.2.12
0.2.02
0.1.92
0.1.72
0.1.62
0.1.52
0.1.42
0.1.32
0.1.22
0.1.19
0.1.02
0.0.12

Package Sidebar

Install

npm i javascript-barcode-reader

Weekly Downloads

1,678

Version

0.6.9

License

MIT

Unpacked Size

255 kB

Total Files

72

Last publish

Collaborators

  • mubaidr