Skip to content

Instantly share code, notes, and snippets.

@leeky
Created April 22, 2015 13:31
Show Gist options
  • Save leeky/6cd3f3692c365865d35d to your computer and use it in GitHub Desktop.
Save leeky/6cd3f3692c365865d35d to your computer and use it in GitHub Desktop.
Convert PNG to base64 encoded string
require 'base64'
File.open('./outfile.txt','w') {|f| f.write "data:image/png;base64," + Base64.strict_encode64(File.read('./input.png'))}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment