Open acrolink opened 8 years ago
No, but that wouldn't be too hard. There are a bunch of libraries out there that do, but I don't know of any in elixir. It wouldn't be hard to add a png mode. I was just having fun when I did this one because I thought it would be neat to print a barcode to console.
To do png, you might use egd, or you could just create your own png if you want to have fun. This site has an example PNG parser in Elixer. You could use no compression, or probably more likely, you would use the Up compression mode with RLE, so basically you draw one line uncompressed 1bit greyscale and then put in the binary code to dump enough zeros to make it the desired height. Alternatively, you could also just raster the entire image however you want, then use :zlib.deflate from erlang. I'm not really sure there would be much of a difference, except deflate would take a few more clock cycle. PNG also uses crc, which I believe is also compatible with :zlib.crc32. There are docs for zlib on the erlang site. You can also do some fun stuff like baking the scaling into the png file.
This one only does Code 128 stuff, so not much can be put in there, btw. Not sure that I do any optimization or detection of data coming in to determine best code or anything.
If there really are no other good elixir/erlang barcode libraries and you don't feel up to it, I'll fix this thing up to at least dump out some PNGs for you.
There is a qrcode library out there, if that's more like what you are looking for, too. https://github.com/komone/qrcode
I plan on doing some qrcode stuff, eventually. Also was planning on doing it to the console using the ascii block drawing quarter blocks.
Oh, I'm also curious what you are trying to do with it, but you don't have to tell me if it's secret. :)
I built this as a start toward QR codes. I already know Code 128 pretty well, so started there. My plan is to eventually implement Steve Gibson's SQRL. I thought it might be neat to have a console implementation of it, in case you had a script that called an API protected by SQRL. Also want to do web support of it, but most of the work would probably be javascript (I would probably just send the nonce to the browser and draw the qr on a canvas or something). There are javascript implementations of qrcodes already.
Thank you very much @samterrell for the detailed explanation. I am not in urgent need for this feature since I have just had my first day with elixir/phoenix yesterday :-) I generate currently png's and even embed them within .docx
files within the NodeJS
framework. I guess, for my particular needs I can just use any shell script than can generate PNG's of bar codes and simply call the shell script from within Elixir/Erlang
. Generating .docx
files with bar code images is vital in the context of warehouse management. Thank you for the valuable information, Elixir/Erlang/Phoenix
looks really promising. I need to choose between learning this framework now and learning J2EE
for web development.
I came from J2EE, and I'm not looking back. :smile:
I've done some work with SweetXml to import excel sheets for one of my apps. I can pull out a snippet of that code, I'm sure. XML manipulation is not fun in any language. Cracking open the zip and editing the files in the xlsx file was easy enough, though using the zlib
module in erlang, and SweetXml adds sigils for XPath expressions, so it's not the worst experience. I also use an erlang "port" for communicating with openoffice to transcode some documents to pdf. If you have any trouble with Elixir stuff, don't be afraid to ask. The community is awesome.
Thanks @samterrell .. I have already tested J2EE on Eclipse/Tomcat. Again both J2EE and Elixir are very new concepts to me. So far, it is clear that things can be done much faster with Elixir/Phoenix than with J2EE. I have some experience with Rails but what made me look for something else is speed/performance. I had tested Phoenix yesterday with ab/httperf
and I simply could not believe my eyes looking at replies/second (5x speed difference in favor of Phoenix). Simply amazing.
Thank.