Skip to content

Instantly share code, notes, and snippets.

@datermine
Created August 31, 2013 16:03
Show Gist options
  • Select an option

  • Save datermine/6399150 to your computer and use it in GitHub Desktop.

Select an option

Save datermine/6399150 to your computer and use it in GitHub Desktop.
A little util for opening an image and then outputting it as as base64 string.
import base64
filename = "bg_gosling.jpg"
encoded_data = base64.encodestring(open(filename, "rb").read())
# Optionally view encoded_data to verify it worked
text_file = open("out.txt", "w")
text_file.write(encoded_data)
text_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment