jsqr vs qr-image vs qr.js vs qrious vs react-qr-code
QR Code Libraries
jsqrqr-imageqr.jsqriousreact-qr-codeSimilar Packages:

QR Code Libraries

QR code libraries in JavaScript provide tools for generating and reading QR codes. These libraries can be used in web applications to create QR codes for URLs, text, or other data, as well as to scan and decode QR codes using a device's camera. They are useful for a variety of applications, including payment systems, marketing, and data sharing. jsqr is a fast and lightweight QR code scanner library that can decode QR codes from images or video streams. qr-image is a Node.js library for generating QR code images in various formats, such as PNG, SVG, and PDF. qr.js is a simple and lightweight library for generating QR codes in the browser using JavaScript. qrious is a feature-rich library for creating QR codes with customizable options, such as size, colors, and error correction levels. react-qr-code is a React component for generating QR codes in React applications, allowing for easy integration and customization.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
jsqr04,004-965 years agoApache-2.0
qr-image01,063-159 years agoMIT
qr.js0---13 years agoMIT
qrious01,626-439 years agoGPL-3.0
react-qr-code087013.8 kB159 months agoMIT

Feature Comparison: jsqr vs qr-image vs qr.js vs qrious vs react-qr-code

Scanning

  • jsqr:

    jsqr is designed for scanning QR codes from images or video streams. It is optimized for performance and can decode QR codes quickly, making it suitable for real-time applications.

  • qr-image:

    qr-image does not support scanning; it is focused on generating QR code images.

  • qr.js:

    qr.js does not support scanning; it is a library for generating QR codes only.

  • qrious:

    qrious does not support scanning; it is a library for generating QR codes with customizable options.

  • react-qr-code:

    react-qr-code does not support scanning; it is a React component for generating QR codes.

Generation

  • jsqr:

    jsqr does not support QR code generation; it is focused on scanning and decoding QR codes.

  • qr-image:

    qr-image is a powerful library for generating QR code images in various formats, including PNG, SVG, and PDF. It is suitable for server-side applications that need to create QR codes dynamically.

  • qr.js:

    qr.js is a simple and lightweight library for generating QR codes in the browser. It creates QR codes using pure JavaScript and does not rely on any external dependencies.

  • qrious:

    qrious is a feature-rich QR code generator that allows for customization of the QR code's appearance, including size, colors, and error correction levels. It is suitable for applications that need more control over the design of the QR codes.

  • react-qr-code:

    react-qr-code is a React component that generates QR codes based on the data provided through props. It is easy to use and integrates seamlessly with React applications.

Customization

  • jsqr:

    jsqr does not offer customization options as it is focused on scanning QR codes.

  • qr-image:

    qr-image allows for some customization of the generated QR codes, such as setting the size and margin. However, it does not provide advanced customization features.

  • qr.js:

    qr.js offers basic customization options for the generated QR codes, such as setting the size and color. It is a simple library without advanced customization features.

  • qrious:

    qrious provides extensive customization options for QR code generation, including setting the size, colors, and error correction levels. It is ideal for applications that require more control over the appearance of the QR codes.

  • react-qr-code:

    react-qr-code allows for customization of the QR code's size and colors through props. It is designed to be simple and easy to use within React applications.

Integration

  • jsqr:

    jsqr can be easily integrated into web applications for real-time QR code scanning. It works well with HTML5 video elements and can be used in conjunction with other libraries for a complete scanning solution.

  • qr-image:

    qr-image is designed for server-side integration with Node.js applications. It can be used to generate QR codes dynamically based on user input or other data.

  • qr.js:

    qr.js is a lightweight library that can be easily integrated into web applications for client-side QR code generation. It does not have any dependencies, making it easy to include in projects.

  • qrious:

    qrious can be integrated into web applications for QR code generation with customizable options. It is a standalone library that does not have any dependencies.

  • react-qr-code:

    react-qr-code is specifically designed for React applications, making it easy to integrate and use within React components.

Ease of Use: Code Examples

  • jsqr:

    Scanning QR codes with jsqr

    import jsQR from 'jsqr';
    const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
    const code = jsQR(imageData.data, imageData.width, imageData.height);
    if (code) {
      console.log('QR Code Data:', code.data);
    }
    
  • qr-image:

    Generating QR code images with qr-image

    const qr = require('qr-image');
    const svg = qr.image('Hello, World!', { type: 'svg' });
    svg.pipe(require('fs').createWriteStream('qr.svg'));
    
  • qr.js:

    Generating QR codes with qr.js

    import QRCode from 'qr.js';
    const qr = new QRCode('Hello, World!');
    const canvas = document.getElementById('qr-canvas');
    const context = canvas.getContext('2d');
    // Render QR code on canvas
    
  • qrious:

    Customizing QR codes with qrious

    import { Qrious } from 'qrious';
    const qr = new Qrious({
      element: document.getElementById('qr'),
      value: 'Hello, World!',
      size: 200,
      background: '#ffffff',
      foreground: '#000000',
    });
    
  • react-qr-code:

    Using react-qr-code in React

    import QRCode from 'react-qr-code';
    const MyComponent = () => (
      <QRCode value="Hello, World!" size={128} />
    );
    

How to Choose: jsqr vs qr-image vs qr.js vs qrious vs react-qr-code

  • jsqr:

    Choose jsqr if you need a fast and efficient library for scanning QR codes from images or video streams. It is ideal for applications that require real-time QR code scanning with minimal resource usage.

  • qr-image:

    Choose qr-image if you need to generate QR code images on the server side using Node.js. It supports multiple output formats and is suitable for applications that require dynamic QR code generation.

  • qr.js:

    Choose qr.js if you need a lightweight and simple library for generating QR codes in the browser. It is easy to use and does not have any dependencies, making it ideal for small projects.

  • qrious:

    Choose qrious if you need a more advanced QR code generator with customizable options. It allows you to set colors, sizes, and error correction levels, making it suitable for applications that require more control over the appearance of the QR codes.

  • react-qr-code:

    Choose react-qr-code if you are building a React application and need a simple way to generate QR codes as React components. It is easy to integrate and allows for customization through props.

README for jsqr

jsQR

Build Status

A pure javascript QR code reading library. This library takes in raw images and will locate, extract and parse any QR code found within.

Demo

Installation

NPM

Available on npm. Can be used in a Node.js program or with a module bundler such as Webpack or Browserify.

npm install jsqr --save
// ES6 import
import jsQR from "jsqr";

// CommonJS require
const jsQR = require("jsqr");

jsQR(...);

Browser

Alternatively for frontend use jsQR.js can be included with a script tag

<script src="jsQR.js"></script>
<script>
  jsQR(...);
</script>

A note on webcams

jsQR is designed to be a completely standalone library for scanning QR codes. By design it does not include any platform specific code. This allows it to just as easily scan a frontend webcam stream, a user uploaded image, or be used as part of a backend Node.js process.

If you want to use jsQR to scan a webcam stream you'll need to extract the ImageData from the video stream. This can then be passed to jsQR. The jsQR demo contains a barebones implementation of webcam scanning that can be used as a starting point and customized for your needs. For more advanced questions you can refer to the getUserMedia docs or the fairly comprehensive webRTC sample code, both of which are great resources for consuming a webcam stream.

Usage

jsQR exports a method that takes in 3 arguments representing the image data you wish to decode. Additionally can take an options object to further configure scanning behavior.

const code = jsQR(imageData, width, height, options?);

if (code) {
  console.log("Found QR code", code);
}

Arguments

  • imageData - An Uint8ClampedArray of RGBA pixel values in the form [r0, g0, b0, a0, r1, g1, b1, a1, ...]. As such the length of this array should be 4 * width * height. This data is in the same form as the ImageData interface, and it's also commonly returned by node modules for reading images.
  • width - The width of the image you wish to decode.
  • height - The height of the image you wish to decode.
  • options (optional) - Additional options.
    • inversionAttempts - (attemptBoth (default), dontInvert, onlyInvert, or invertFirst) - Should jsQR attempt to invert the image to find QR codes with white modules on black backgrounds instead of the black modules on white background. This option defaults to attemptBoth for backwards compatibility but causes a ~50% performance hit, and will probably be default to dontInvert in future versions.

Return value

If a QR is able to be decoded the library will return an object with the following keys.

  • binaryData - Uint8ClampedArray - The raw bytes of the QR code.
  • data - The string version of the QR code data.
  • chunks - The QR chunks.
  • version - The QR version.
  • location - An object with keys describing key points of the QR code. Each key is a point of the form {x: number, y: number}. Has points for the following locations.
    • Corners - topRightCorner/topLeftCorner/bottomRightCorner/bottomLeftCorner;
    • Finder patterns - topRightFinderPattern/topLeftFinderPattern/bottomLeftFinderPattern
    • May also have a point for the bottomRightAlignmentPattern assuming one exists and can be located.

Because the library is written in typescript you can also view the type definitions to understand the API.

Contributing

jsQR is written using typescript. You can view the development source in the src directory.

Tests can be run with

npm test

Besides unit tests the test suite contains several hundred images that can be found in the /tests/end-to-end/ folder.

Not all the images can be read. In general changes should hope to increase the number of images that read. However due to the nature of computer vision some changes may cause images that pass to start to fail and visa versa. To update the expected outcomes run npm run-script generate-test-data. These outcomes can be evaluated in the context of a PR to determine if a change improves or harms the overall ability of the library to read QR codes. A summary of which are passing and failing can be found at /tests/end-to-end/report.json

After testing any changes, you can compile the production version by running

npm run-script build

Pull requests are welcome! Please create seperate branches for seperate features/patches.