📇 QR Code
Generate QR codes in Deno, as base64-encoded images, completely dependency-free and requires no binary.
This is a port of zenozeng/node-yaqrcode, which itself is a port of the QR code generator in the d-project.
import { qrcode } from "https://raw.githubusercontent.com/denorg/qrcode/master/mod.ts";
const base64Image = qrcode("bitcoin:ADDRESS?amount=0.5&label=ORDER"); // data:image/gif;base64,...
You can also add a custom size by specifying size
in the second parameter:
const fixedSizeImage = qrcode("bitcoin:ADDRESS?amount=0.5&label=ORDER", { size: 500 });
Alternatively, you can use it directly from the CLI:
deno run https://raw.githubusercontent.com/denorg/qrcode/master/cli.ts <text>
You can also install it globally using the following:
deno install qrcode https://raw.githubusercontent.com/denorg/qrcode/master/cli.ts
Then, the package is available to run:
qrcode <text>
👩💻 Development
Run tests:
deno test
Notes
- To support typeNumber 40, use the
RS_BLOCK_TABLE
from davidshimjs/qrcodejs - To support UTF-8, use the code from davidshimjs/qrcodejs
- Returns a base64-encoded image URL
📄 License
- MIT © Denorg
- Original repo: MIT © Zeno Zeng
- "QR Code" is registered trademark of Denso Wave