Created
November 8, 2014 18:35
-
-
Save riocampos/495d31b96a07357751cb to your computer and use it in GitHub Desktop.
image encoding to text by Base64 (refer: http://d.hatena.ne.jp/yuheiomori0718/20111209/1323432840 )
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
#!/usr/bin/env ruby | |
require 'base64' | |
print "image filename: " | |
image_name = gets.chomp | |
filename = image_name.sub(/\.(\w+)$/) { "_base64_#{$1}.txt" } | |
open(filename, 'w') { |f| f.write(Base64.encode64(open(image_name).read).tr("\n", "")) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment