Skip to content

Instantly share code, notes, and snippets.

@juno
Created November 17, 2010 02:40
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 juno/702897 to your computer and use it in GitHub Desktop.
Save juno/702897 to your computer and use it in GitHub Desktop.
for ruby 1.9 / Usage: img2base64 [filename]
#!/usr/bin/env ruby
require 'base64'
f = open(ARGV[0])
data = f.read
f.close
puts "data:image/png;base64,#{Base64.encode64(data).gsub(/\n/, '')}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment