Over a million developers have joined DZone.

Create A QR Code

·
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 }
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}