Skip to content

Instantly share code, notes, and snippets.

@juno juno/img2base64.rb

Created Nov 17, 2010
What would you like to do?
for ruby 1.9 / Usage: img2base64 [filename]
#!/usr/bin/env ruby
require 'base64'
f = open(ARGV[0])
data =
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
You can’t perform that action at this time.