| Index: packagerChrome.py |
| diff --git a/packagerChrome.py b/packagerChrome.py |
| index d75203d17b9e63262e69f44e5112cfc729005d8d..82fe95801ef0cd8bbaf8cf4ff59b8c0f1d3cb420 100644 |
| --- a/packagerChrome.py |
| +++ b/packagerChrome.py |
| @@ -43,13 +43,13 @@ 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 |
| + png_tuple = (137, 'PNG', '\r\n', '\x1a', '\n') |
| + header = struct.unpack('>B3s2scc', files[filename][0:8]) |
|
Sebastian Noack
2017/09/20 00:58:00
There is no reason to split the magic number into
tlucas
2017/09/20 08:52:49
Done.
|
| + assert header == png_tuple, '{} is no valid PNG.'.format(filename) |
|
Vasily Kuznetsov
2017/09/19 17:52:26
Python's `assert` is not a reliable method to test
Sebastian Noack
2017/09/20 00:58:00
I'd like to add that the general idea of programmi
tlucas
2017/09/20 08:52:49
Thanks for the insight - restructured this code al
|
| + |
| + width, height = struct.unpack('>ii', files[filename][16:24]) |
| if(width != height): |
| print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be square' % (filename, width, height) |
| icons[width] = filename |