Qr image
Yet another QR code generator
* No dependecies; * generate image in `png`, `svg`, `eps` and `pdf` formats; * numeric and alphanumeric modes; * support UTF-8. The project is written primarily in JavaScript, distributed under the MIT License license, first published in 2014. It has gained significant community traction with 1,065 stars and 164 forks on GitHub. Key topics include: javascript, qr, qrcode.
Latest release: v3.2.0
December 22, 2016View Changelog →
qr-image
This is yet another QR Code generator.
Overview
- No dependecies;
- generate image in
png,svg,epsandpdfformats; - numeric and alphanumeric modes;
- support UTF-8.
Installing
shellnpm install qr-image
Usage
Example:
javascriptvar qr = require('qr-image'); var qr_svg = qr.image('I love QR!', { type: 'svg' }); qr_svg.pipe(require('fs').createWriteStream('i_love_qr.svg')); var svg_string = qr.imageSync('I love QR!', { type: 'svg' });
Example For generate images in client side:
javascriptvar qr = require('qr-image'); router.get('/qr', function(){ var code = qr.image('http://www.google.com', { type: 'png' }); res.setHeader('Content-type', 'image/png'); //sent qr image to client side code.pipe(res); });
then in the html files:
<img src="/qr" alt="qrcode">
qr = require('qr-image')
Methods
qr.image(text, [ec_level | options])— Readable stream with image data;qr.imageSync(text, [ec_level | options])— string with image data. (Buffer forpng);qr.svgObject(text, [ec_level | options])— object with SVG path and size;qr.matrix(text, [ec_level])— 2D array of booleans. Y is indexed first (e.g.[y][x]NOT[x][y]),[0][0]is the top left, andtruemeans black.
Options
text— text to encode;ec_level— error correction level. One ofL,M,Q,H. DefaultM.options— image options object:ec_level— defaultM.type— image type. Possible valuespng(default),svg,pdfandeps.size(png and svg only) — size of one module in pixels. Default5for png andundefinedfor svg.margin— white space around QR image in modules. Default4forpngand1for others.customize(only png) — function to customize qr bitmap before encoding to PNG.parse_url(experimental, defaultfalse) — try to optimize QR-code for URLs.
Changes
- Use
zlib.deflateSyncinstead ofpako. - Fix deprecation warning for NodeJS 7.
TODO
- Tests;
- mixing modes;
- Kanji (???).
Contributors
Showing top 8 contributors by commit count.
This article is auto-generated from alexeyten/qr-image via the GitHub API.Last fetched: 6/21/2026
