Created
November 10, 2019 01:26
-
-
Save harsh183/e3539c9d4b204aee44e066e6fc308c96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pry' | |
require 'rqrcode' | |
qrcode = RQRCode::QRCode.new('https://cs125.cs.illinois.edu') | |
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: 600 | |
) | |
logo_size = 200 | |
cs125_png = ChunkyPNG::Image.from_file('cs125.png') | |
cs125_png = cs125_png.resize(logo_size, logo_size) | |
png = png.compose(cs125_png, png.width/2 - logo_size/2, png.height/2 - logo_size/2) | |
# binding.pry | |
IO.write("/tmp/github-qrcode.png", png.to_s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quick and dirty approach but considering how noisy QR codes tend to be works decently well actually. Make sure to test your code before running with it, and perhaps then you can run a loop with it till it works. All this is pure ruby so
Adapted parts from the rqrcode docs on RDoc, more helpful information available there.