GithubHelp home page GithubHelp logo

qr-image's Introduction

qr-image

npm version

This is yet another QR Code generator.

Overview

  • No dependecies;
  • generate image in png, svg, eps and pdf formats;
  • numeric and alphanumeric modes;
  • support UTF-8.

Releases

Installing

npm install qr-image

Usage

Example:

var 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:

var 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">

More examples

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 for png);
  • 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, and true means black.

Options

  • text — text to encode;
  • ec_level — error correction level. One of L, M, Q, H. Default M.
  • options — image options object:
    • ec_level — default M.
    • type — image type. Possible values png (default), svg, pdf and eps.
    • size (png and svg only) — size of one module in pixels. Default 5 for png and undefined for svg.
    • margin — white space around QR image in modules. Default 4 for png and 1 for others.
    • customize (only png) — function to customize qr bitmap before encoding to PNG.
    • parse_url (experimental, default false) — try to optimize QR-code for URLs.

Changes

  • Use zlib.deflateSync instead of pako.
  • Fix deprecation warning for NodeJS 7.

TODO

  • Tests;
  • mixing modes;
  • Kanji (???).

qr-image's People

Contributors

alexeyten avatar brockers avatar david-boles avatar eins78 avatar kj-huang avatar mrose17 avatar nullstyle avatar odeke-em avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qr-image's Issues

Size doesn't work

Size doesn't work
let code = qr.image(text, {type: 'png', size: 10});

Add text below or above QR-image

Hello I'm working on webapp for our company and i was asked to create QR Code generator with text above or below Code. Is tthere any way to add this texts in to image?

temppng00

Incompatible PNG when running on Raspberry Pi (ARMv6)

When running this on X86 Linux or X86 Mac:

var qr = require('qr-image');
var fs = require('fs');
var readable = qr.image('hi', {type: 'png', size: 1});
var writable = fs.createWriteStream('qr.png');
readable.pipe(writable);

I get good images.

However, when running on a Raspberry Pi (ARMv6) I get an invalid PNG file.

Here's a hex dump of the invalid PNG:

89504E47 0D0A1A0A 0000000D 49484452 0000001D 0000001D 08000000 00FFFFFF 
FE000000 80494441 5478DAC5 525B0EC0 3008E2FE 97665914 C5CDF46F 593F9A5A 
7C800A9E 0EBE4511 271E6D09 95E38DB5 5517E21F 89033BCA 03CA3D56 3EDCEA26 
4B28EFE0 DCF2F277 EA65798F B78A14A9 B826A1E0 A3C2B444 156A9908 3E515120 
CD9A1473 1A9B5EF5 D107E3BD C2166B95 0D7BCD08 2794A597 5C7763D5 8BDE8E67 
AF7ED8F6 0B896C64 B8000005 75000000 0049454E 44AE4260 82

Here's a hex dump of the good PNG:

89504E47 0D0A1A0A 0000000D 49484452 0000001D 0000001D 08000000 0073F838 
D3000000 80494441 5478DAC5 525B0EC0 3008E2FE 97665914 C5CDF46F 593F9A5A 
7C800A9E 0EBE4511 271E6D09 95E38DB5 5517E21F 89033BCA 03CA3D56 3EDCEA26 
4B28EFE0 DCF2F277 EA65798F B78A14A9 B826A1E0 A3C2B444 156A9908 3E515120 
CD9A1473 1A9B5EF5 D107E3BD C2166B95 0D7BCD08 2794A597 5C7763D5 8BDE8E67 
AF7ED8F6 0B896C64 B8974AAE 14000000 0049454E 44AE4260 82

The header looks good but it goes off the rails around the 00FFFFFF at the end of the top line.

Possibly some sort of big-endian / little-endian issue?

node version: v0.11.11-pre

Firefox and Chrome generation differ

I'm sorry but generating a fiddle is really hard since this library require imports etc.
The following

        let buffer = qr.imageSync("hello", {
            ec_level: 'H',
            margin: 1,
            type: 'png'
        })

generate 2 different results in firefox and chrome. The problem seems only related fo FF 48 (and 49 beta) on mac.

[Question] Optimize the size for better reading

Hi there,

First of all, thank you for this package, it work flawlessly!

I am trying to optimize the detection of a qr code. I already set the error correction to HIGH.

My QR code is pretty small (5 alphaNum characters). Id like to make the modules as big as possible to prevent bad reading.

I've done some research, my 5 alphaNum code can be stored in a Version 1 (21 modules x 21) QR Code with high correction level (can store up to 10 alphaNum characters).

My qrCode need to be 5.5cm by 5.5 cm.
This mean that the module size should be 0.2619 cm (5.5 / 21 = 0.2619)

I am currently outputting my qrCode as pdf files.
As stated in the doc, the size option only affect png & svg files.

Is there a way i can set my module size to 0.2619 cm ? (Or it equivalent in px with the good dpi)

Can i do it with pdf files ? Do i need to switch to another format ? (I hope not, would be way easier with pdf files but if i can't, i'll find a solution)

Also, i'm pretty sure it's not but it's worth asking : Is it possible to reduce the number of modules (say 15 modules x 15) in order to make the individual module bigger ?

Thanks a lot in advance !

# not supported

I use this library to generate a qr code for a url with '#', but resulting qr code not include '#' and after

How to control the SVG path dimensions?

I understand this is a generic SVG question, though I am assuming a few people will struggle with the same query when using qr-image.

The SVG output produces a path and size, e.g.

{ size: 29,
  path: 'M0 0h7v7h-7zM9 0h5v1h1v-1h1v1h2v-1h3v2h-1v-1h-1v1h1v1h-1v1h1v1h-3v3h-1v1h-1v-1h-1v-2h1v1h1v-1h-1v-1h1v-1h1v-1h1v-1h-1v1h-1v1h-2v-1h1v-1h-1v1h-1v-1h-1v-1h-1v1h1v2h-1v-1h-2v2h1v1h-1v2h-1v-6h1zM22 0h7v7h-7zM1 1v5h5v-5zM23 1v5h5v-5zM2 2h3v3h-3zM24 2h3v3h-3zM20 3h1v1h-1zM11 5h1v1h-1zM10 6h1v1h1v-1h1v3h2v1h1v1h-2v1h-1v-2h-1v-2h-1v2h-3v-1h1v-1h1zM18 6h1v1h-1zM20 6h1v2h-2v-1h1zM0 8h1v1h-1zM2 8h5v1h-2v1h-1v-1h-1v1h-2v-1h1zM17 8h2v1h-2zM22 8h5v1h-1v1h-1v1h1v1h-2v1h-1v-1h-1v1h1v1h1v-1h2v2h-1v1h-1v1h-1v-2h-1v-1h-1v2h-1v-2h-1v-1h2v-2h3v-1h-5v-1h3zM16 9h1v1h-1zM27 9h2v1h-2zM0 10h1v1h-1zM6 10h1v1h-1zM11 10h1v2h-1zM17 10h1v1h-1zM26 10h1v1h-1zM1 11h2v1h-1v1h-1zM4 11h1v1h2v-1h2v1h1v1h2v-1h1v2h-1v2h-1v-2h-1v1h-1v1h-1v-1h-2v-1h3v-1h-3v1h-1v1h1v1h-1v4h-1v1h-2v-1h1v-1h1v-1h-1v1h-1v-1h-1v3h-1v-4h3v-1h1v-1h-2v-2h1v1h1zM16 11h1v1h-1zM19 11h1v1h-1zM14 12h2v1h-2zM17 12h2v1h-2zM26 12h2v1h-2zM16 13h1v1h-1zM28 13h1v1h-1zM15 14h1v1h1v1h3v2h-1v-1h-4v-1h-1v-1h1zM18 14h1v1h-1zM27 14h1v1h1v1h-1v1h1v1h-2v-1h-2v-1h2zM1 15h1v1h-1zM6 16h1v1h-1zM12 16h1v1h-1zM21 16h1v1h-1zM7 17h1v1h-1zM9 17h2v1h-1v1h-1zM13 17h2v1h1v1h-2v1h-1v1h-1v-2h1zM22 17h1v1h-1zM24 17h1v1h-1zM6 18h1v1h-1zM11 18h1v1h-1zM18 18h1v1h-1zM25 18h2v1h-2zM7 19h1v1h2v1h-1v1h-1v-1h-3v-1h2zM19 19h3v1h1v-1h2v1h2v-1h1v2h-1v1h-1v-1h-1v3h2v1h-7v-1h-1v-2h1v-2h-1zM14 20h2v1h-2zM17 20h2v1h-2zM10 21h2v1h-1v2h-1v1h-1v2h-1v-4h1v-1h1zM16 21h1v1h1v1h-3v-1h1zM21 21v3h3v-3zM28 21h1v1h-1zM0 22h7v7h-7zM22 22h1v1h-1zM27 22h1v2h-1zM1 23v5h5v-5zM14 23h1v1h-1zM2 24h3v3h-3zM11 24h2v1h-1v1h1v-1h2v1h-1v1h-1v2h-1v-2h-1v1h-2v-1h1v-2h1zM15 24h3v1h-3zM18 25h1v1h1v1h-2zM27 25h2v1h-1v2h-1zM15 26h1v2h4v1h-5v-1h-1v-1h1zM21 26h5v1h-1v1h-1v1h-2v-1h1v-1h-1v1h-2v-1h1zM8 28h1v1h-1zM26 28h1v1h-1z' }

The size is equal to the size of one module.

But what if you want to display QR code of a particular size, e.g. 200x200px?

imageSync

Hello.

I added imageSync method to use your npm with templating engines. That's Handlebars in my case.

The only thing that I had no time to deal with was deflating the bitmap.data in png-sync.js; if you could finish that, imageSync could be a nice addition to your npm, it's great to use with wkhtmltopdf for SVG qr-codes.

Thanks.

qr-image with href

I want to add qr-image with href so user can click on it but svg has so many double quotes so it's not working. What is the best way to print svg qrcode in this case?

Example:

var svg_img = qr.imageSync('http://www.gizmo.com/link/', { type: 'svg' });
$("#qrdiv").html('<a href="http://www.gizmo.com/link/" target="_blank"><img src="'+svg_img+'"/></a>');

Size option not working for SVG

Hi, I'm trying to generate an SVG image that I can embed onto a pdf document but the size option is not working. Please check the code below.

var qrImage = require('qr-image');

var svgObject = qrImage.svgObject('my data here', { 
  type: 'svg',
  size: 200 // width should be 200px
}); 

It seems the only way to change size is by changing the ec_level option. Any idea how I can fix this?

Can't set image width and height?

This is my code:
(My system is win7)

var qr = require('qr-image');

var png_string = qr.imageSync("http://www.google.com/");
 fs.writeFile("e:/qrcodes/"+data[i].name+".png", png_string, 'utf8');

Default ,Createed images width and height is 225 pixel. I need width and height is 2000 pixel.
Please help me ,Thx !

QR code with transparent background and specific color

Hello,

I've a question. It's possible to generate a qr code with transparent background and with specific color like white by exemple and not black?

Thanks in advance for your response and if it's not possible, can you implement it?

Best regards

Generated content different in Microsoft Edge

The library seems to be generating different content in Microsoft Edge (for both SVG and PNG), causing the QR code to be corrupt. This seems to occur more often for longer content.

Code:

'use strict';

var qr = require('qr-image');

var uri = 'https://[::1]/apps/foo/index.html?qid=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
var image = qr.imageSync(uri, {type: 'svg'});
console.log(image);

Output (in Microsoft Edge 13.10586):

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 43 43"><path d="M1 1h7v7h-7zM11 1h4v1h-1v1h-1v-1h-1v1h-1v1h-1v4h1v-3h1v-1h1v1h1v-1h1v2h2v1h-1v1h-1v-1h-1v1h-1v-2h-1v3h1v1h1v-1h2v1h-1v1h2v2h-1v-1h-3v-1h-1v2h4v1h-1v1h2v-2h2v1h1v-2h1v-1h-1v1h-1v-1h-1v-2h1v1h1v-2h1v-2h-1v2h-1v-2h-1v-2h1v1h1v-2h1v-1h-2v1h-1v-2h5v1h-1v1h4v1h1v2h3v-1h1v1h1v2h-1v-1h-1v2h-2v1h-1v1h3v-2h2v-1h1v-3h-1v-2h1v-2h1v10h1v2h-2v2h-1v-1h-1v1h1v1h-3v1h3v-1h1v-1h2v1h-1v1h-1v2h-1v-1h-1v1h1v1h-3v1h3v-1h1v-1h2v1h-1v1h-1v2h-1v-1h-1v1h1v1h1v-1h2v1h-1v1h-1v2h-1v-1h-1v1h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h1v-1h1v1h1v-1h-1v-1h2zM23 27h1v1h-1zM25 27h1v2h-1zM29 28v1h2v-1zM40 28h1v1h-1zM23 29h1v1h-1zM34 29h1v1h-1zM37 29v1h1v-1zM3 30h2v1h-2zM24 30h1v1h-1zM40 30h2v1h-2zM6 31h2v1h-1v1h-1zM13 31h1v1h-1zM16 31h1v1h1v1h-1v1h-1v1h-2v-1h-1v-1h3zM23 31h1v1h-1zM25 31h1v2h-1zM28 31h1v1h-1zM36 31v1h1v-1zM2 32h1v2h-1zM27 32h1v3h-1v-1h-1v-1h1zM40 32h1v1h-1zM5 33h1v1h-1zM7 33h2v1h-2zM23 33h1v1h-1zM9 34h2v2h1v2h-1v-1h-1v2h1v1h1v2h-1v-1h-1v-1h-1v-4h1v-1h-1zM12 34h1v1h-1zM24 34h1v1h-1zM31 34v1h2v-1zM34 34v3h3v-3zM40 34h2v1h-2zM1 35h7v7h-7zM13 35h1v1h-1zM16 35h1v1h1v1h-1v1h-1v1h1v1h1v1h-1v1h-4v-1h3v-1h-1v-2h-2v-1h3zM23 35h1v1h-1zM25 35h1v2h-1zM28 35h1v1h-1zM35 35h1v1h-1zM2 36v5h5v-5zM27 36h1v3h-1v-1h-1v-1h1zM40 36h1v1h-1zM3 37h3v3h-3zM18 37h1v1h-1zM23 37h1v1h-1zM12 38h1v1h-1zM17 38h1v1h-1zM24 38h1v1h-1zM35 38v1h1v-1zM40 38h2v1h-2zM13 39h1v1h-1zM25 39h1v2h-1zM28 39h1v1h-1zM36 40v1h1v-1zM40 40h1v1h-1zM9 41h1v1h-1zM18 41h1v1h-1zM26 41h2v1h-2z"/></svg>

Expected output (in IE 11, Chrome 49, and Firefox 45.0.2):

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 43 43"><path d="M1 1h7v7h-7zM10 1h1v2h1v-2h2v1h1v-1h1v2h1v1h-1v2h1v1h-1v1h-1v-2h-1v-1h1v-2h-2v1h-2v1h2v2h-1v3h-1v-1h-2v-6h1zM20 1h1v1h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h2v1h-1v1h2v1h1v1h-2v1h-3v-1h-1v-2h1v-1h1zM39 37h1v1h2v1h-3zM20 38h2v1h-2zM23 38h3v1h-2v1h2v1h-2v1h-1v-1h-1v-1h1zM27 38h1v1h-1zM35 38v1h1v-1zM14 40h1v1h2v1h-3zM17 40h1v1h-1zM30 40v1h1v-1zM40 40h1v1h-1zM9 41h1v1h-1zM18 41h3v1h-3zM26 41h2v1h-2zM34 41h1v1h-1z"/></svg>

provide an svg-only build

We use your lib with browserify. Works great so far.

Would be even better if there would be a svg-only build to minimize filesize.

qr = require('qr-image/svg')

I think this would be easily possible just by shifting some code around. I this would be of interest I would create a PR for this.

Inverse mode

Is it's possible to inverse the qr code result?
Black to be white and white to be black.

Standalone version of svg_object, making it possible to use it dependency free in the browser

Greetings and thanks for the excellent library.

As it is the library has a hard dependency on nodejs caused by the use of two constructs:

  1. Readable, with its single use being in the qr_image function
  2. Buffer, used across the library

With this small set of backward compatible changes (sent as a Pull Request #50) it becomes possible to create a browser standalone version of svg_object packing the following snippet of code with webpack

window.svg_object = require('qr-image/lib/svg-object');

Including the generated javascript file it becomes possible dynamically create QR Codes in the browser in a completely independent and standalone fashion with no additional dependencies (not even nodejs).

`

    <head>

        <meta charset='utf-8' />

        <title>Standalone SVG Object example</title>

        <script type='application/javascript' src='svg-object.js'></script>

        <script>

        // Passes the arguments to svg_object, returns an DOM element with the resulting SVG

        function createQRCodeElement() {

            var NS = 'http://www.w3.org/2000/svg';

            var args = [].slice.call(arguments);

            var svg_obj = svg_object.apply(this, args);

            var viewBox = '0 0 ' + svg_obj.size + ' ' + svg_obj.size;

            var svg_element = document.createElementNS(NS, 'svg');

            svg_element.setAttribute('viewBox', viewBox);

            var path_element = document.createElementNS(NS, 'path');

            path_element.setAttribute('d', svg_obj.path);

            svg_element.appendChild(path_element);

            return svg_element;

        }

        window.onload = function() {

            var svg_element = createQRCodeElement('Hello World');

            document.getElementById('qrCode').appendChild(svg_element);

        }

        </script>

        <style>

            #qrCode {

                width: 100px;

                height: 100px;

            }

            #qrCode > svg {

                width: 100%;

                height: 100%;

            }

        </style>

    </head>

    <body>

        <div id="qrCode">&nbsp;</div>

    </body>

</html>`

The end result of said script is what's visible below, a QR Code created inline at the page. The compiled js plus the sample html are attached to this issue as well

screenshot - 01_08_2018 18_09_53

Best Regards

can I encode newline

Input text "a\nb". Encoding "utf-8"

Using a QR code reader to scan the output svg, consecutive newlines are squeezed to a single space char.

What can I do?

The generated EPS file is corrupted

I've tried to create a QR code file in EPS file, the generated file cannot be opened by GIMP & InkShape. May I know anything special need to be set in options ?

Below is my testing code:

var qr = require('qr-image');

var qr_eps = qr.image('I love QR!', { type: 'eps' });
qr_eps.pipe(require('fs').createWriteStream('i_love_qr.eps'));

corrupted images

Some times i am getting corrupted images. is there any way to fix or recreate the same again?

Hi, question about png_sync

I'm using "customize" option to make a logo into the qr.

I found there is a function in png.png_sync(bitmap) can convert thebitmap to png buffer.
But I didn't find a function that revert a png buffer to bitmap buffer.

Could you help me ?

Support JPEG image format

Currently, only (lossless) PNG, SVG, EPS and PDF formats are supported, but (lossy) JPEG is also a common format for images. It could be a valuable addition to support.

cannot install

while i run: npm install qr-image
if apper error: can resolve it?

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/egg
npm ERR!   peer egg@"^3.12.0" from [email protected]  
npm ERR!   node_modules/egg-mock
npm ERR!     peerOptional egg-mock@">=5.8.3" from [email protected]
npm ERR!     node_modules/egg-bin
npm ERR!       dev egg-bin@"^5" from the root project
npm ERR!     dev egg-mock@"^5" from the root project
npm ERR!   egg@"^3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer egg@"^2.26.0" from [email protected]
npm ERR! node_modules/egg-websocket-plugin
npm ERR!   egg-websocket-plugin@"^1.0.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/egg
npm ERR!   peer egg@"^2.26.0" from [email protected]
npm ERR!   node_modules/egg-websocket-plugin
npm ERR!     egg-websocket-plugin@"^1.0.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\Administrator\AppData\Local\npm-cache\_logs\2023-05-08T02_55_59_318Z-eresolve-report.txt        

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Local\npm-cache\_logs\2023-05-08T02_55_59_318Z-debug-0.log

showing text as url

if we put a url in place of text and later when we put txt it will still show the text as url

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.