How to generate QR code in Ruby

How to generate a QR code in Ruby

QR Code

Install gem:

1
gem install rqrcode

Ruby code

1
2
3
4
5
6
7
8
9
10
11
12
13
require 'rqrcode'
qrcode = RQRCode::QRCode.new("https://www.yuxifan.com/")
png = qrcode.as_png(
resize_gte_to: false,
resize_exactly_to: false,
fill: 'white',
color: 'black',
size: 360,
border_modules: 4,
module_px_size: 6,
file: "/var/tmp/qrx360.png"
)
Share