Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: packagerChrome.py

Issue 29501558: Issue 5383 - Add tests for the Chrome and Firefox packagers (Closed)
Patch Set: Simplifying parameters Created Sept. 21, 2017, 11:27 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « README.md ('k') | tests/README.md » ('j') | tests/test_packagerEdge.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packagerChrome.py
diff --git a/packagerChrome.py b/packagerChrome.py
index d75203d17b9e63262e69f44e5112cfc729005d8d..bb2f33d8808fc9d06f189007d0788991dd310b4e 100644
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -43,13 +43,15 @@ def processFile(path, data, params):
def makeIcons(files, filenames):
- try:
- from PIL import Image
- except ImportError:
- import Image
icons = {}
for filename in filenames:
- width, height = Image.open(StringIO(files[filename])).size
+ try:
+ magic, width, height = struct.unpack_from('>8s8xii',
+ files[filename])
+ except struct.error:
+ magic = None
+ if magic != '\x89PNG\r\n\x1a\n':
+ raise TypeError(filename + ' is no valid PNG.')
Sebastian Noack 2017/09/21 19:09:03 The definition of TypeError doesn't seem to apply
tlucas 2017/09/22 09:02:18 Done.
if(width != height):
print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be square' % (filename, width, height)
icons[width] = filename
« no previous file with comments | « README.md ('k') | tests/README.md » ('j') | tests/test_packagerEdge.py » ('J')

Powered by Google App Engine
This is Rietveld