Created
August 1, 2011 19:11
-
-
Save ingeniarius/1118795 to your computer and use it in GitHub Desktop.
Convert binary file to data URI base64 encoded
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 'base64' | |
file = ARGV[0] | |
mimetype = `file -b --mime-type #{file}`.gsub(/\n/,'') | |
puts "data:#{mimetype};base64," << Base64.encode64(File.read(file)).gsub(/\n/, '') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment