DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Create A QR Code

01.26.2011
| 3195 views |
  • submit to reddit
        Create a QR code.

require 'rubygems'
require 'rqrcode'
require 'qr_image'

# QR Code parameters
text = 'This is a test'
size = 4
level = 'h'
 
# Produce the QR Code
qr = RQRCode::QRCode.new(text,  :size => size, :level => level)
 
# Create the image and double its size
img = QRImage.new(qr).sample(6)
 
# Write image to disk
img.write('./qr.png') { quality = 100 }