Created
December 5, 2010 04:27
-
-
Save mhayes/728791 to your computer and use it in GitHub Desktop.
Converts text to QR Code using Google Charts API
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 'net/http' | |
require 'uri' | |
print <<INFO | |
QR Code Generator | |
Generated codes will be saved to "label.png" in the current directory | |
INFO | |
print "Text to encode: " | |
label_contents = gets.strip | |
begin | |
res = Net::HTTP.post_form URI.parse('http://chart.apis.google.com/chart'), | |
{ :cht => "qr", "chl" => label_contents, :chs => "200x200" } | |
File.open("label.png", "w") {|f| f.write res.body} | |
rescue | |
print "Unable to generate QR Code" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment