rqr

Get Version

0.2.2

What

A ruby library to create qrcode. Output: PS, JPEG, PNG, EPS, TIFF.

A QR code is a 2-dimensional “barcode” of a type popular in Japan. It is intended for transferring chunks of data such as long URLs using a camera (Eg. on a phone), together with decoding software.

There is more information at http://en.wikipedia.org/wiki/QR_Code and at http://www.denso-wave.com/qrcode/index-e.html.

REQUIREMENTS

Linux

If using Linux, Install libs with yum command.

$ sudo yum install libjpeg
$ sudo yum install libpng
$ sudo yum install libtiff

OSX

If using OSX, Use Fink Universal Binary libs.

$ sudo fink install libjpeg
$ sudo fink install libpng
$ sudo fink install libtiff

or use MacPorts (http://www.macports.com)

$ sudo port install jpeg
$ sudo port install libpng
$ sudo port install tiff

Windows

Nothing to do. rqr for win32 include binary lib.

Installing

sudo gem install rqr

Demonstration of usage

Sample1: Simple usage

require "rubygem"
require "rqr"

# Define a file format with extensions.
RQR::QRCode.create do |qr|
  qr.save("http://www.amazon.com", "path/to/qrcode.jpg")
end

#Define a file format with symbol.
RQR::QRCode.create do |qr|
  qr.save("http://www.amazon.com", "path/to/qrcodefile", :png)
end

Sample2: Creating EPS with preview

require "rubygem"
require "rqr"

# QRCode options (passed to RQR::QRCode.new())
# Use options with hash values.
# :level       L:0, M:1(default), Q:2, H:3
#  (determines how fault tolerant the code is.)
# :version     S:0(default), M:1, L:2
# :auto_extent  true|false auto extent if over version size
# :masking     masking pattern 0-7, -1(default auto)
# :length      data length
# :module_size module size (pixel)
# :eps_preview true|false

# This sample creates a EPS with preview.
RQR::QRCode.new(:eps_preview => true, :auto_extent=false) do |qr|
  qr.save("http://www.ebay.com", "path/to/qrcode.eps")
end

Sample3: Old style

require "rubygem"
require "rqr"

# Old style for (0.2.0, 0.1.1, 0.1.0)
qr = RQR::QRCode.new()

# Define a file format with extensions.
qr.save("http://www.google.com", "path/to/qrcode.jpg")

# Define a file format with symbol.
qr.save("http://www.yahoo.com", "path/to/qrcodefile", :png)

License

This code is free to use under the terms of the MIT license.

Contact

Comments are welcome. Send an email via the rubyforge

RyotaMaruko, 16th August 2008
Theme extended from Paul Battley, by Daniel Cadenas via DepGraph