Browse Source

Merge pull request #5489

905711f contrib: improve optimize-pngs.py (Wladimir J. van der Laan)
42f6a0c [Qt] optimize PNG files (Jonas Schnelli)
0.13
Wladimir J. van der Laan 10 years ago
parent
commit
d1aa3c67f0
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 73
      contrib/devtools/optimize-pngs.py
  2. BIN
      src/qt/res/icons/about.png
  3. BIN
      src/qt/res/icons/about_qt.png
  4. BIN
      src/qt/res/icons/add.png
  5. BIN
      src/qt/res/icons/address-book.png
  6. BIN
      src/qt/res/icons/bitcoin.png
  7. BIN
      src/qt/res/icons/clock1.png
  8. BIN
      src/qt/res/icons/clock2.png
  9. BIN
      src/qt/res/icons/clock3.png
  10. BIN
      src/qt/res/icons/clock4.png
  11. BIN
      src/qt/res/icons/clock5.png
  12. BIN
      src/qt/res/icons/configure.png
  13. BIN
      src/qt/res/icons/connect0.png
  14. BIN
      src/qt/res/icons/connect1.png
  15. BIN
      src/qt/res/icons/connect2.png
  16. BIN
      src/qt/res/icons/connect3.png
  17. BIN
      src/qt/res/icons/connect4.png
  18. BIN
      src/qt/res/icons/debugwindow.png
  19. BIN
      src/qt/res/icons/edit.png
  20. BIN
      src/qt/res/icons/editcopy.png
  21. BIN
      src/qt/res/icons/editpaste.png
  22. BIN
      src/qt/res/icons/export.png
  23. BIN
      src/qt/res/icons/eye.png
  24. BIN
      src/qt/res/icons/eye_minus.png
  25. BIN
      src/qt/res/icons/eye_plus.png
  26. BIN
      src/qt/res/icons/filesave.png
  27. BIN
      src/qt/res/icons/history.png
  28. BIN
      src/qt/res/icons/info.png
  29. BIN
      src/qt/res/icons/key.png
  30. BIN
      src/qt/res/icons/lock_closed.png
  31. BIN
      src/qt/res/icons/lock_open.png
  32. BIN
      src/qt/res/icons/open.png
  33. BIN
      src/qt/res/icons/overview.png
  34. BIN
      src/qt/res/icons/quit.png
  35. BIN
      src/qt/res/icons/receive.png
  36. BIN
      src/qt/res/icons/remove.png
  37. BIN
      src/qt/res/icons/send.png
  38. BIN
      src/qt/res/icons/synced.png
  39. BIN
      src/qt/res/icons/transaction0.png
  40. BIN
      src/qt/res/icons/transaction2.png
  41. BIN
      src/qt/res/icons/transaction_conflicted.png
  42. BIN
      src/qt/res/icons/tx_inout.png
  43. BIN
      src/qt/res/icons/tx_input.png
  44. BIN
      src/qt/res/icons/tx_mined.png
  45. BIN
      src/qt/res/icons/tx_output.png
  46. BIN
      src/qt/res/icons/verify.png
  47. BIN
      src/qt/res/movies/spinner-000.png
  48. BIN
      src/qt/res/movies/spinner-001.png
  49. BIN
      src/qt/res/movies/spinner-002.png
  50. BIN
      src/qt/res/movies/spinner-003.png
  51. BIN
      src/qt/res/movies/spinner-004.png
  52. BIN
      src/qt/res/movies/spinner-005.png
  53. BIN
      src/qt/res/movies/spinner-006.png
  54. BIN
      src/qt/res/movies/spinner-007.png
  55. BIN
      src/qt/res/movies/spinner-008.png
  56. BIN
      src/qt/res/movies/spinner-009.png
  57. BIN
      src/qt/res/movies/spinner-010.png
  58. BIN
      src/qt/res/movies/spinner-011.png
  59. BIN
      src/qt/res/movies/spinner-012.png
  60. BIN
      src/qt/res/movies/spinner-013.png
  61. BIN
      src/qt/res/movies/spinner-014.png
  62. BIN
      src/qt/res/movies/spinner-015.png
  63. BIN
      src/qt/res/movies/spinner-016.png
  64. BIN
      src/qt/res/movies/spinner-017.png
  65. BIN
      src/qt/res/movies/spinner-018.png
  66. BIN
      src/qt/res/movies/spinner-019.png
  67. BIN
      src/qt/res/movies/spinner-020.png
  68. BIN
      src/qt/res/movies/spinner-021.png
  69. BIN
      src/qt/res/movies/spinner-022.png
  70. BIN
      src/qt/res/movies/spinner-023.png
  71. BIN
      src/qt/res/movies/spinner-024.png
  72. BIN
      src/qt/res/movies/spinner-025.png
  73. BIN
      src/qt/res/movies/spinner-026.png
  74. BIN
      src/qt/res/movies/spinner-027.png
  75. BIN
      src/qt/res/movies/spinner-028.png
  76. BIN
      src/qt/res/movies/spinner-029.png
  77. BIN
      src/qt/res/movies/spinner-030.png
  78. BIN
      src/qt/res/movies/spinner-031.png
  79. BIN
      src/qt/res/movies/spinner-032.png
  80. BIN
      src/qt/res/movies/spinner-033.png
  81. BIN
      src/qt/res/movies/spinner-034.png
  82. BIN
      src/qt/res/movies/spinner-035.png

73
contrib/devtools/optimize-pngs.py

@ -0,0 +1,73 @@
#!/usr/bin/env python
import os
import sys
import subprocess
import hashlib
from PIL import Image
def file_hash(filename):
'''Return hash of raw file contents'''
with open(filename, 'rb') as f:
return hashlib.sha256(f.read()).hexdigest()
def content_hash(filename):
'''Return hash of RGBA contents of image'''
i = Image.open(filename)
i = i.convert('RGBA')
data = i.tostring()
return hashlib.sha256(data).hexdigest()
#optimize png, remove various color profiles, remove ancillary chunks (alla) and text chunks (text)
#pngcrush -brute -ow -rem gAMA -rem cHRM -rem iCCP -rem sRGB -rem alla -rem text
pngcrush = 'pngcrush'
git = 'git'
folders = ["src/qt/res/movies", "src/qt/res/icons", "src/qt/res/images"]
basePath = subprocess.check_output([git, 'rev-parse', '--show-toplevel']).rstrip('\n')
totalSaveBytes = 0
outputArray = []
for folder in folders:
absFolder=os.path.join(basePath, folder)
for file in os.listdir(absFolder):
extension = os.path.splitext(file)[1]
if extension.lower() == '.png':
print("optimizing "+file+"..."),
file_path = os.path.join(absFolder, file)
fileMetaMap = {'file' : file, 'osize': os.path.getsize(file_path), 'sha256Old' : file_hash(file_path)};
fileMetaMap['contentHashPre'] = content_hash(file_path)
pngCrushOutput = ""
try:
pngCrushOutput = subprocess.check_output(
[pngcrush, "-brute", "-ow", "-rem", "gAMA", "-rem", "cHRM", "-rem", "iCCP", "-rem", "sRGB", "-rem", "alla", "-rem", "text", file_path],
stderr=subprocess.STDOUT).rstrip('\n')
except:
print "pngcrush is not installed, aborting..."
sys.exit(0)
#verify
if "Not a PNG file" in subprocess.check_output([pngcrush, "-n", "-v", file_path], stderr=subprocess.STDOUT):
print "PNG file "+file+" is corrupted after crushing, check out pngcursh version"
sys.exit(1)
fileMetaMap['sha256New'] = file_hash(file_path)
fileMetaMap['contentHashPost'] = content_hash(file_path)
if fileMetaMap['contentHashPre'] != fileMetaMap['contentHashPost']:
print "Image contents of PNG file "+file+" before and after crushing don't match"
sys.exit(1)
fileMetaMap['psize'] = os.path.getsize(file_path)
outputArray.append(fileMetaMap)
print("done\n"),
print "summary:\n+++++++++++++++++"
for fileDict in outputArray:
oldHash = fileDict['sha256Old']
newHash = fileDict['sha256New']
totalSaveBytes += fileDict['osize'] - fileDict['psize']
print fileDict['file']+"\n size diff from: "+str(fileDict['osize'])+" to: "+str(fileDict['psize'])+"\n old sha256: "+oldHash+"\n new sha256: "+newHash+"\n"
print "completed. Total reduction: "+str(totalSaveBytes)+" bytes"

BIN
src/qt/res/icons/about.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
src/qt/res/icons/about_qt.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/icons/add.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 712 B

BIN
src/qt/res/icons/address-book.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
src/qt/res/icons/bitcoin.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 KiB

After

Width:  |  Height:  |  Size: 306 KiB

BIN
src/qt/res/icons/clock1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
src/qt/res/icons/clock2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/qt/res/icons/clock3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
src/qt/res/icons/clock4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
src/qt/res/icons/clock5.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
src/qt/res/icons/configure.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
src/qt/res/icons/connect0.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
src/qt/res/icons/connect1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
src/qt/res/icons/connect2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
src/qt/res/icons/connect3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
src/qt/res/icons/connect4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
src/qt/res/icons/debugwindow.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
src/qt/res/icons/edit.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
src/qt/res/icons/editcopy.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 883 B

BIN
src/qt/res/icons/editpaste.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
src/qt/res/icons/export.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/qt/res/icons/eye.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
src/qt/res/icons/eye_minus.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
src/qt/res/icons/eye_plus.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
src/qt/res/icons/filesave.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
src/qt/res/icons/history.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 762 B

BIN
src/qt/res/icons/info.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
src/qt/res/icons/key.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/qt/res/icons/lock_closed.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
src/qt/res/icons/lock_open.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
src/qt/res/icons/open.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/qt/res/icons/overview.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
src/qt/res/icons/quit.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
src/qt/res/icons/receive.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
src/qt/res/icons/remove.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/qt/res/icons/send.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/qt/res/icons/synced.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
src/qt/res/icons/transaction0.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
src/qt/res/icons/transaction2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
src/qt/res/icons/transaction_conflicted.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
src/qt/res/icons/tx_inout.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
src/qt/res/icons/tx_input.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/qt/res/icons/tx_mined.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
src/qt/res/icons/tx_output.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/qt/res/icons/verify.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
src/qt/res/movies/spinner-000.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
src/qt/res/movies/spinner-001.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-002.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-003.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-004.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-005.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-006.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-007.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
src/qt/res/movies/spinner-008.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-009.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
src/qt/res/movies/spinner-010.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-011.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-012.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-013.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-014.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-015.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-016.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
src/qt/res/movies/spinner-017.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
src/qt/res/movies/spinner-018.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
src/qt/res/movies/spinner-019.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-020.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-021.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-022.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-023.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-024.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-025.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
src/qt/res/movies/spinner-026.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
src/qt/res/movies/spinner-027.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
src/qt/res/movies/spinner-028.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-029.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-030.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-031.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-032.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-033.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/qt/res/movies/spinner-034.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
src/qt/res/movies/spinner-035.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Loading…
Cancel
Save