qrencoder
by Jacob Harris
http://www.nimblecode.com/
http://nycrb.rubyforge.org/qrencoder
DESCRIPTION:
This Gem is a wrapper around an useful open-source library for creating QR Codes, a two-dimensional bar code format popular in Japan (and readable by cell phones even) created by the Denso-Wave Corporation in 1994. These bar codes look like the following:
The specification for QR Code is readable at www.denso-wave.com/qrcode/index-e.html. QR Code is not the only 2-D barcode standard in existence, and it is in wider use in Japan than elsewhere. Notable competitors include PDF417, Semacode/DataMatrix, and Maxi Code (seen on UPS labels) in North America; ShotCode in the UK; and an additional format used in Korea. All vary in look and capacity, but QR Code has one of the largest information densities and capacities among them with the following maximum data
-
Numeric 7,089
-
Alphanumeric 4,296
-
8-Bit 2,953
-
Kanji 1,817
All of these in a square that may range from 21 to 177 pixels a side (there are 40 different “versions” of the code that specify different sizes). In addition, multiple levels of error correction are possible which might also influence the final size.
USAGE:
Basic usage is as follows:
text = "Some string"
qrcode = QREncoder.encode(text) #=> #<QREncoder::QRCode:0x1003710d0>
puts "#{qrcode.version}" #=> 7
puts "#{qrcode.width}" #=> 34
qrcode.save_png("/tmp/foo.png")
You can retrieve the pixels of the QR Code object directly or use the included methods to save a PNG file directly.
See the rdocs for options you can pass to QREncoder#encode
.
REQUIREMENTS:
This gem requires you to build the C library lib 111qrcode.a
available from megaui.net/fukuchi/works/qrencode/index.en.html.
On *nix systems, installation is usually as simple as:
curl http://fukuchi.org/works/qrencode/qrencode-3.2.0.tar.gz | tar xz
cd qrencode-3.2.0
./configure
make
sudo make install
If it worked, you should be able to type qrencode
and get a help message.
Normally, the build process also expects you to have libpng
, but this is only used for the qrenc
command-line utility and can be avoided if you run the following build sequence:
./configure --without-tools
make
sudo make install
HOMEBREW:
If you’re on OS X, you can use homebrew to install libqrencode:
brew install qrencode
INSTALLATION:
-
First build the
libqrencode
library following the instructions above. -
Then
[sudo] gem install qrencoder
DEVELOPMENT AND CONTRIBUTING:
This project uses Bundler and its own gemspec for dependency management. To get started, just clone the repo and run:
gem install bundler
bundle install
rake
The default Rake task will compile the C component and run the specs. If it fails to build, make sure that you have libqrencode installed properly.
Please send pull requests. Topic branches are preferred. New features will not be accepted without corresponding tests.
FEATURES/PROBLEMS:
-
This gem requires you to build and install an external C library
-
The QREncode lib this GEM is built around is NOT thread-safe!
CONTRIBUTORS:
-
Jacob Harris (harrisj)
-
Joshua Davey (jgdavey)
-
Joseph Holsten
-
Wesley Moore (wezm)
QRCODE LICENSE:
The QR Code specification was created and patented by the Denso Corporation of Japan. Although the Denso Corporation retains their patent, it is “open in the sense that the specification of QR Code is disclosed and that the patent right owned by Denso Wave is not exercised.” according to their website.
LICENSE:
(The MIT License)
Copyright © 2007
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.