qr_code_maker

A simple, zero-dependency, standard-library-only QR code generator for Ruby.

qr_code_maker is written in pure Ruby, with no external gem dependencies. It supports standard QR Codes (Versions 1-40, ECC levels L, M, Q, H), central logo image overlays (PNG, JPEG, SVG), and color customization.


Installation

Add this line to your application's Gemfile:

gem 'qr_code_maker'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install qr_code_maker

Usage

1. Basic QR Codes

require 'qr_code_maker'

# Generate a raw SVG string
svg = QrCodeMaker.generate_svg("https://github.com")

# Generate an ASCII terminal representation
ascii = QrCodeMaker.generate_ascii("https://github.com")
puts ascii

# Generate a PNG image string
png = QrCodeMaker.generate_png("https://github.com")
File.binwrite("qrcode.png", png)

2. QR Codes with Central Logo & Custom Colors

You can easily embed a central logo image (file path to PNG/JPEG/SVG or raw SVG string) inside the QR code. High Error Correction (level: :h) is automatically selected when a logo is provided to guarantee 100% scannability:

require 'qr_code_maker'

# Generate SVG QR code with central logo
svg = QrCodeMaker.generate_svg(
  "https://apple.com",
  logo: "path/to/logo.png",
  color: "#1C1C1E"
)
File.write("qr_logo.svg", svg)

# Generate PNG QR code with central logo
png = QrCodeMaker.generate_png(
  "https://apple.com",
  logo: "path/to/logo.png",
  color: "#1C1C1E"
)
File.binwrite("qr_logo.png", png)

# Custom Colors & Finder Pattern Colors
svg_custom = QrCodeMaker.generate_svg(
  "https://bitcoin.org",
  logo: "path/to/icon.png",
  color: "#333333",        # Main module color
  finder_color: "#F2A900", # Corner finder patterns color
  bg_color: "white"       # Background color
)

Running Tests

Run the automated test suite with:

ruby -Ilib:test test/test_qr_code_maker.rb

License

The gem is available as open source under the terms of the MIT License.