Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: client/testing/dartest/resources/img2base64.py

Issue 8905021: Dartest CL - Please review (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:executable
+ *
OLDNEW
(Empty)
1 #!/usr/bin/python
pdr 2011/12/14 21:02:36 There's a small effort to rewrite these types of s
shauvik 2011/12/16 07:19:27 Okay - that would be the next exercise after I get
2 """
3 Converts an image into its Base-64 data string
4 Useful for embedding images in HTML or CSS without having a separate file
5 """
6
7 import sys,base64
8
9 if __name__ == "__main__":
10 if(len(sys.argv) < 2):
11 print "Usage: img2base64.py <image>"
12 exit(1)
13 try:
14 fName = sys.argv[1]
15 data = base64.encodestring(open(fName,"rb").read()).replace('\n', '')
16 fType = fName[-3:] #Use last 3 chars as file type
17 print "data:image/%s;base64,%s"%(fType,data)
18 except IOError as e:
19 print "Failed to open file:", sys.argv[1]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698