This is yet another QR Code generator (based on alexeyten/qr-image).
- generate image in
png
,svg
andpdf
formats - numeric and alphanumeric modes
- support UTF-8
npm install @shortcm/qr-image
# or
yarn add @shortcm/qr-image
Example:
const qr = require('@shortcm/qr-image');
// or
import qr from '@shortcm/qr-image';
const svgString = await qr.image('I love QR!', { type: 'svg' });
const svgWithLogoString = await qr.image('I love QR!', { type: 'svg', logo: fs.openFileSync('my logo') });
qr.image(text, [options])
: Readable stream with image data.qr.matrix(text, [ec_level], [parse_url])
: 2D array of "booleans" (numbers). Y is indexed first (e.g.[y][x]
NOT[x][y]
),[0][0]
is the top left, and1
(true
) means black.
text
: text to encodeoptions
: image options objectec_level
: one ofL
,M
,Q
,H
; defaultM
type
: image type; possible valuespng
,svg
andpdf
; defaultpng
size
: (typespng
andsvg
only) size of one module in pixels; default5
forpng
and0
forsvg
margin
: white space around QR image in modules; default4
forpng
and1
for othersparse_url
: (experimental) try to optimize QR-code for URLs; defaultfalse
logo
: buffer with PNG image; defaultundefined
logoWidth
: height of image (in percent); default20
logoHeight
: width of image (in percent); default20
color
: dot color in RGBA format; does not support CSS syntax; must be number; default0x000000FF
for black with 100% opacitybgColor
: background color in RGBA format; does not support CSS syntax; must be number; default0xFFFFFFFF
for white with 100% opacity
- Use
zlib.deflateSync
instead ofpako
- Fix deprecation warning for NodeJS 7
customize
function removed
- Tests
- mixing modes
- Kanji (???)