Fast QR Code png generator for Ruby
This library sacrificed everything for speed. It is only suitable for people who just need a plain QR Code png.
gem install cheetah_qrcoderequire 'cheetah_qrcode'
# ==== Attributes
# * +text+ - Text to generate QR Code, required
# * +:ec_level+ - Error correction level for QR Code, accepts :L, :M, :Q, :H, default is :M
# * +:border+ - Quiet zone modules outside of QR Code, default is 4
# * +:size+ - Output image size, cannot be smaller than QR Code modules size, default is QR Code modules size
CheetahQRCode.encode('test', ec_level: :q, border: 0, size: 600)If the specified size is slightly larger than the QR Code modules size, there will be some sort of image distortion due to limitation of 1 bit png. Use larger size or QR Code modules size to prevent this issue.
require 'benchmark'
require 'rqrcode'
require 'cheetah_qrcode'
text = 'xtufa+wH4Fh/gx2uKgv/r8IRv2ZNV94b4v983GUouFRMT6k5'
puts "RQRCode: #{RQRCode::VERSION}, RQRCodeCore: #{RQRCodeCore::VERSION}, ChunkyPNG: #{ChunkyPNG::VERSION}"
Benchmark.bm do |x|
x.report do
1000.times do
RQRCode::QRCode.new(text, level: :q).as_png(border_modules: 4, size: 300).to_blob
end
end
end
puts "CheetahQRCode: #{CheetahQRCode::VERSION}"
Benchmark.bm do |x|
x.report do
1000.times do
CheetahQRCode.encode(text, ec_level: :q, border: 4, size: 300)
end
end
endRQRCode: 2.2.0, RQRCodeCore: 1.2.0, ChunkyPNG: 1.4.0
user system total real
44.220344 0.030486 44.250830 ( 44.250962)
CheetahQRCode: 1.0.4
user system total real
0.437743 0.000000 0.437743 ( 0.437775)
This project includes files from the following repos:
License notices for their work are included either in file headers or by license file besides included files.