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

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
« no previous file with comments | « client/testing/dartest/resources/expand.png ('k') | client/testing/dartest/resources/max.png » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:executable
+ *
OLDNEW
(Empty)
1 #!/usr/bin/python
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
« no previous file with comments | « client/testing/dartest/resources/expand.png ('k') | client/testing/dartest/resources/max.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698