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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/testing/dartest/resources/expand.png ('k') | client/testing/dartest/resources/max.png » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
+"""
+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
+ *
« 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