Home

Awesome

Update

This code base is no longer being developed. I have started this project with intent to allow Firefox OS apps developers add barcode/qrcode scanning capability to their apps, as well build simple barcode/qrcode scanner. Since Mozilla withdrawal from Firefox OS project I see much less interest in this library.

If anyone would like to continue porting feel free to fork the project. Let me know about the fork. I'm happy to link to it from README file.

zxingjs

JavaScript port of popular zxing library. Work in progress. Plan:

  1. Reading popular barcodes (DONE)
  2. Reading QR codes (in progress)
  3. Documentation, examples and tests for points
  4. Reading RSS
  5. Reading Data Matrix
  6. Generating barcodes
  7. Generating QR codes
  8. Generating RSS codes
  9. Generating Data Matrix codes
  10. More documentation, examples and tests
  11. Clean-up and optimizations (mostly speed, as well refactoring code to be a bit more JS friendly, supporting more environments)

Dependencies:

Quick and dirty example

require([
    'zxing/oned/MultiFormatOneDReader',
    'zxing/BinaryBitmap',
    'zxing/RGBLuminanceSource',
    'zxing/common/GlobalHistogramBinarizer'
], function (MultiFormatOneDReader, BinaryBitmap, RGBLuminanceSource, GlobalHistogramBinarizer) {
    try {
        var canvas = document.getElementById('canvas');
        var image  = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height);

        var reader = new MultiFormatOneDReader();
        var bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(new RGBLuminanceSource(canvas.width, canvas.height, image.data)));
        var result = reader.decode(bitmap, {});
    } catch (e) {
    }
});

For more details please wait for documentation and examples, or refer to source code and original zxing library. This JavaScript port tries to stay as close to original as possible.