Git Product home page Git Product logo

Comments (9)

soldair avatar soldair commented on August 25, 2024 6

@gabzim
look like you can pass width and height in options if you set the type to be png to any function that makes a png file.

toDataURL toFile toFileStream

this should totally be documented. sorry friend.

https://github.com/soldair/node-qrcode/blob/master/lib/renderer/png.js#L10

from node-qrcode.

soldair avatar soldair commented on August 25, 2024

Every qr code version requires a specific number of points on a grid.
To make qr codes always one size you must force the version to a specific
value and set the size in pixels of the point.
The version you pick will govern the maximum amount of data you can store.
On Jul 17, 2011 2:27 PM, "tixelated" <
[email protected]>
wrote:

Hi - would love to help make QR code image sizes configurable at run time,
any pointers?

Reply to this email directly or view it on GitHub:
#4

from node-qrcode.

 avatar commented on August 25, 2024

Right. Another way to deal with it is to come from the other direction - have the size setting be tied to the point size, rather than the overall image. Developers could then do some quick experimenting (or math) to determine the best fit for their app. So - not really "200px x 200px" but rather "Version 2 @ 8px per point" (= 200px x 200px, and the developer can dial down the point size or version if they want to make it smaller.)

I guess I should ask - are point sizes configurable right now? If so then it's all set, I didn't see that -

from node-qrcode.

soldair avatar soldair commented on August 25, 2024

I think they are. In the object its a property called module or something
ambiguous :).
When I get home I will look.
On Jul 17, 2011 5:10 PM, "tixelated" <
[email protected]>
wrote:

Right. Another way to deal with it is to come from the other direction -
have the size setting be tied to the point size, rather than the overall
image. Developers could then do some quick experimenting (or math) to
determine the best fit for their app. So - not really "200px x 200px" but
rather "Version 2 @ 8px per point" (= 200px x 200px, and the developer can
dial down the point size or version if they want to make it smaller.)

I guess I should ask - are point sizes configurable right now? If so then
it's all set, I didn't see that -

Reply to this email directly or view it on GitHub:
#4 (comment)

from node-qrcode.

soldair avatar soldair commented on August 25, 2024

right now based on my interface its not possible without going deeper than my inital export.
if i expose a config value that lets you hardset the QRCode level you would generate codes of predictable size.

QRCode.QRCodeDraw.scale = 10;// this value has a bad name but its the size in pixels of the black square
QRCode.QRCodeDraw.QRErrorCorrectLevel = 1;// least error correction. these do not sort numerically 
//---------- not real. proposed interface
QRCode.QRCodeDraw.QRLevel = 11;// a level
//----------

QRCode.QRCodeDraw.draw(new Canvas(200,200),text,function(error,canvas){
cb(error,canvas)
});

i could find in the version capacity table here
https://github.com/soldair/node-qrcode/blob/master/lib/qrcapacitytable.js
that my max characters would be 321
each black square would be 10 px because i configured the scale variable

from node-qrcode.

 avatar commented on August 25, 2024

That would be pretty useful - "auto" by default, or hard set by the developer. In all of our use cases, we know the text size ahead of time and can truncate accordingly if necessary to get some predictability. I would imagine this is pretty common...

from node-qrcode.

vigreco avatar vigreco commented on August 25, 2024

I think this has been solved in latest releases 👍

from node-qrcode.

gabzim avatar gabzim commented on August 25, 2024

I need to generate qr codes of 512x512, how was this solved? there's no info on this, btw, I'm on node.js, not HTML/canvas.

from node-qrcode.

gabzim avatar gabzim commented on August 25, 2024

@soldair thanks for the info and speed! much appreciated!

from node-qrcode.

Related Issues (20)

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.