JSPM

qrim

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q23354F
  • License MIT

Stylized JavaScript QR Code image generator with UTF8 support.

Package Exports

  • qrim
  • qrim/build/qrim.module.js
  • qrim/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (qrim) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Qrim

Qrim (QR Image Maker), a JavaScript library for generating QR Code images.

Origianly forked from qrcode.js. Removed legacy code, refactored to support ES modules, included UTF8 character support, and added stylization options.

Install

  • Option 1: Copy file qrim.module.js, import from file...
import { QRCode } from 'qrim.module.js';
  • Option 2: Install from npm, import from 'qrim'...
npm install qrim
import { QRCode } from 'qrim';
  • Option 3: Import directly from CDN...
import { QRCode } from 'https://unpkg.com/qrim/build/qrim.module.js';

Usage

<div id="qrcode"></div>

<script type='module'>

import { QRCode } from 'qrim';

const el = document.getElementById("qrcode");
const qr = new QRCode(el, "http://www.code.com");

</script>

Options

Parameters object, all properties are optional

const qr = new QRCode(el, {
    text: "http://www.domain.com",          // text to generate
    size: 1024,                             // image dimensions
    colorDark : "#000000",                  // block color
    colorLight : "#ffffff",                 // background color
    border: 1,                              // border size, in # of blocks
    padding: 1,                             // padding size, in # of blocks
    opacity: 1,                             // image opacity
    style: QRCode.Styles.Square,            // Square | Blob | Dots
    correctLevel: QRErrorCorrectLevel.H,    // L | M | Q | H
});

Methods

// make new code from new text
qr.makeCode("http://www.newcode.com");

// ...or make new code from updated parameters
const params = {
    text: "http://www.newcode.com",
    size: 2048,
    opacity: 0.5,
};
qr.makeCode(params);