Changeset View
Changeset View
Standalone View
Standalone View
contrib/devtools/optimize-pngs.py
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | for file in os.listdir(absFolder): | ||||
file_path = os.path.join(absFolder, file) | file_path = os.path.join(absFolder, file) | ||||
fileMetaMap = {'file': file, 'osize': os.path.getsize( | fileMetaMap = {'file': file, 'osize': os.path.getsize( | ||||
file_path), 'sha256Old': file_hash(file_path)} | file_path), 'sha256Old': file_hash(file_path)} | ||||
fileMetaMap['contentHashPre'] = content_hash(file_path) | fileMetaMap['contentHashPre'] = content_hash(file_path) | ||||
try: | try: | ||||
subprocess.call([pngcrush, "-brute", "-ow", "-rem", "gAMA", "-rem", "cHRM", "-rem", "iCCP", "-rem", "sRGB", | subprocess.call([pngcrush, "-brute", "-ow", "-rem", "gAMA", "-rem", "cHRM", "-rem", "iCCP", "-rem", "sRGB", | ||||
"-rem", "alla", "-rem", "text", file_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) | "-rem", "alla", "-rem", "text", file_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) | ||||
except: | except OSError: | ||||
print("pngcrush is not installed, aborting...") | print("pngcrush is not installed, aborting...") | ||||
sys.exit(0) | sys.exit(0) | ||||
# verify | # verify | ||||
if "Not a PNG file" in subprocess.check_output([pngcrush, "-n", "-v", file_path], stderr=subprocess.STDOUT, universal_newlines=True): | if "Not a PNG file" in subprocess.check_output([pngcrush, "-n", "-v", file_path], stderr=subprocess.STDOUT, universal_newlines=True): | ||||
print("PNG file " + file + | print("PNG file " + file + | ||||
" is corrupted after crushing, check out pngcursh version") | " is corrupted after crushing, check out pngcursh version") | ||||
sys.exit(1) | sys.exit(1) | ||||
Show All 24 Lines |