Skip to content

Instantly share code, notes, and snippets.

@mhayes
Created December 5, 2010 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhayes/728791 to your computer and use it in GitHub Desktop.
Save mhayes/728791 to your computer and use it in GitHub Desktop.
Converts text to QR Code using Google Charts API
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