Let's clear up some rQRCode stuff.
QR-code alternatives and similar gems
Based on the "Misc" category
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of QR-code or a related project?
- QR code is trademarked by Denso Wave inc
- Minimum Ruby version is
< 1.0.0please use this README
Add this line to your application's
or install manually:
gem install rqrcode
Basic usage example
require 'rqrcode' qr = RQRCode::QRCode.new('http://github.com') result = '' qr.qrcode.modules.each do |row| row.each do |col| result << (col ? 'X' : 'O') end result << "\n" end puts result
These are the various QR Code generation options provided by rqrqcode_core.
string - the string you wish to encode size - the size of the qrcode (default 4) level - the error correction level, can be: * Level :l 7% of code can be restored * Level :m 15% of code can be restored * Level :q 25% of code can be restored * Level :h 30% of code can be restored (default :h) mode - the mode of the qrcode (defaults to alphanumeric or byte_8bit, depending on the input data): * :number * :alphanumeric * :byte_8bit * :kanji
qrcode = RQRCodeCore::QRCode.new('hello world', size: 1, level: :m, mode: :alphanumeric)
You can output your QR code in various forms. These are detailed below:
The SVG renderer will produce a stand-alone SVG as a
require 'rqrcode' qrcode = RQRCode::QRCode.new("http://github.com/") # NOTE: showing with default options specified explicitly svg = qrcode.as_svg( offset: 0, color: '000', shape_rendering: 'crispEdges', module_size: 6, standalone: true )
[QR code with github url](./images/github-qrcode.svg)
The ANSI renderer will produce as a string with ANSI color codes.
require 'rqrcode' qrcode = RQRCode::QRCode.new("http://github.com/") # NOTE: showing with default options specified explicitly svg = qrcode.as_ansi( light: "\033[47m", dark: "\033[40m", fill_character: ' ', quiet_zone_size: 4 )
[QR code with github url](./images/ansi-screen-shot.png)
The library can produce a PNG. Result will be a
require 'rqrcode' qrcode = RQRCode::QRCode.new("http://github.com/") # NOTE: showing with default options specified explicitly png = qrcode.as_png( bit_depth: 1, border_modules: 4, color_mode: ChunkyPNG::COLOR_GRAYSCALE, color: 'black', file: nil, fill: 'white', module_px_size: 6, resize_exactly_to: false, resize_gte_to: false, size: 120 ) IO.write("/tmp/github-qrcode.png", png.to_s)
[QR code with github url](./images/github-qrcode.png)
On the console ( just because you can )
require 'rqrcode' qr = RQRCode::QRCode.new('http://kyan.com', size: 4, level: :h) puts qr.to_s
xxxxxxx x x xxx xxxxxxx x x xxxxx x x x x x xxx x x x x x xxx x x xxx x xxx x xxx x xxx x x xxx x xxx x x x x xxx x ... etc
- Fork the project
- Send a pull request
- Don't touch the .gemspec, I'll do that when I release a new version
Original RQRCode author: Duncan Robertson
A massive thanks to all the contributors of the library over the years. It wouldn't exist if it wasn't for you all.
Oh, and thanks to my bosses at https://kyan.com for giving me time to maintain this project.
- wikipedia:: http://en.wikipedia.org/wiki/QR_Code
- Denso-Wave website:: http://www.denso-wave.com/qrcode/index-e.html
- kaywa:: http://qrcode.kaywa.com
MIT License (http://www.opensource.org/licenses/mit-license.html)
*Note that all licence references and agreements mentioned in the QR-code README section above are relevant to that project's source code only.