soldair / node-qrcode

qr code generator
MIT License
7.53k stars 627 forks source link

Support svg output #44

Closed adius closed 8 years ago

soldair commented 8 years ago

that would be nice. happy to merge this if someone wants to work on the pull request

soldair commented 8 years ago

im just going to mention we already expose a draw bit array function which returns an array. to render this as svg is just going to be looping it over one more time and generating the markup

it would be nice to have this but dont actually know svg and i dont have time to add this to my weekend project list yet =)

vigreco commented 8 years ago

Hi, I'd like to work on this if you agree. Do you have any preferences / suggestions on the API format?

soldair commented 8 years ago

hey! thats great @vigreco i think that you should add a new function at the bottom of https://github.com/soldair/node-qrcode/blob/master/qrcode.js

you should pass the function aguments directly to drawBitArray just like the drawText does https://github.com/soldair/node-qrcode/blob/master/qrcode.js#L184 and then from the array of bits create the svg and then callback =)

you can put your rendering logic in a file called something like lib/svgrender.js if you like. this copies what i did for lib/terminalrender.js but nothing i did is amazing or perfect so if you feel you want to do it differently that's ok also =)

test coverage is extremely poor at the moment. if you like, please make an independent test file called something like test/svg.js and use tap. i can help with this if you like if you are unfamilliar.

sorry for the delay in replying i wanted to give you proper guidance =)

vigreco commented 8 years ago

Thanks @soldair! I'll start working on this later today. In order to save the svg as a file, do you think is best to export a dedicated function or integrate it in https://github.com/soldair/node-qrcode/blob/master/qrcode.js#L130 and detect which render to use based on the extension of the output file?

soldair commented 8 years ago

Oooh that sounds nice

On Sep 13, 2016 6:29 AM, "Vincenzo Greco" notifications@github.com wrote:

Thanks @soldair https://github.com/soldair! I'll start working on this later today. In order to save the svg as a file, do you think is best to export a dedicated function or integrate it in https://github.com/soldair/ node-qrcode/blob/master/qrcode.js#L130 and detect which render to use based on the extension of the output file?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/soldair/node-qrcode/issues/44#issuecomment-246640593, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHUX-G-OEfAYeV0hcQ4oECGeanmCrfpks5qpnsUgaJpZM4HFAJK .

soldair commented 8 years ago

thanks to @vigreco svg support has landed in v0.5.0 published to npm!

gajus commented 7 years ago

@soldair Whats with the XML output for the SVG?

Thats neither cross-platform friendly or efficient.

Have a look at how https://github.com/alexeyten/qr-image implements it.

Here is an output example https://github.com/alexeyten/qr-image/issues/39

All you need is to return the SVG path.

gajus commented 7 years ago

@soldair Have you tried inviting @alexeyten as a contributor to this project?

Joining efforts would benefit everyone.

soldair commented 7 years ago

Happy to have them on board if they are interested. I believe our core is beyond what qr-image supports now thanks to @vigreco. If either of you would like to contribute a change to output svg thats both cross-platform friendly and efficient im sure it would be welcome =)

vigreco commented 7 years ago

Hi @gajus, I'm not an svg expert, I did some research but I didn't found anything about efficiency or cross-platform friendly svg. Do you mind recommend some link/resource so I can improve my knowledge and possibly improve the code too?

I see though that using an svg path could produce a more concise and less verbose output.