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: Adressing comments Created Sept. 20, 2017, 8:47 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/tools.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..54630bfc12ff5b7e98e9a671e806d4b43e9f9cfe 100644
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -43,13 +43,11 @@ 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
+ magic, width, height = struct.unpack('>8s8xii', files[filename][:24])
Sebastian Noack 2017/09/20 21:36:10 This is different from my suggestion: 1. If you u
tlucas 2017/09/21 11:34:55 Sorry, i somehow overlooked this part from your co
+ if magic != '\x89PNG\r\n\x1a\n':
+ raise TypeError('{} is no valid PNG.'.format(filename))
Sebastian Noack 2017/09/20 21:36:10 Nit; from https://adblockplus.org/coding-style#pyt
tlucas 2017/09/21 11:34:55 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/tools.py » ('J')

Powered by Google App Engine
This is Rietveld