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: Addressing Dave's comments Created Oct. 17, 2017, 12:41 p.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
Index: packagerChrome.py
diff --git a/packagerChrome.py b/packagerChrome.py
index 948a9074ce55b2e359237582c27474efcc1cdad6..873243c38439aeee38060c0ea4aef4206555a658 100644
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -8,7 +8,6 @@ import io
import json
import os
import re
-from StringIO import StringIO
import struct
import subprocess
import sys
@@ -44,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 Exception(filename + ' is no valid PNG.')
if(width != height):
print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be square' % (filename, width, height)
icons[width] = filename

Powered by Google App Engine
This is Rietveld