Chromium Code Reviews| Index: client/testing/dartest/resources/img2base64.py |
| =================================================================== |
| --- client/testing/dartest/resources/img2base64.py (revision 0) |
| +++ client/testing/dartest/resources/img2base64.py (revision 0) |
| @@ -0,0 +1,19 @@ |
| +#!/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
|
| +""" |
| +Converts an image into its Base-64 data string |
| +Useful for embedding images in HTML or CSS without having a separate file |
| +""" |
| + |
| +import sys,base64 |
| + |
| +if __name__ == "__main__": |
| + if(len(sys.argv) < 2): |
| + print "Usage: img2base64.py <image>" |
| + exit(1) |
| + try: |
| + fName = sys.argv[1] |
| + data = base64.encodestring(open(fName,"rb").read()).replace('\n', '') |
| + fType = fName[-3:] #Use last 3 chars as file type |
| + print "data:image/%s;base64,%s"%(fType,data) |
| + except IOError as e: |
| + print "Failed to open file:", sys.argv[1] |
| Property changes on: client/testing/dartest/resources/img2base64.py |
| ___________________________________________________________________ |
| Added: svn:executable |
| + * |