aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-05-05 10:40:35 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-05-05 10:40:39 -0400
commitfbd522721cb89ef0efea0c1bc912c00b268d1c2a (patch)
treeba13ac7e827d3f4f3c437cf44e17d930f4e5732a /contrib
parent52ce396b2a47ed1c5d7d5764bc98a09451001749 (diff)
parentfa13090d2048c9a1e475eb25de756763f8adddb8 (diff)
downloadbitcoin-fbd522721cb89ef0efea0c1bc912c00b268d1c2a.tar.xz
Merge #18885: contrib: Move optimize-pngs.py script to the maintainer repo
fa13090d2048c9a1e475eb25de756763f8adddb8 contrib: Remove optimize-pngs.py script, which lives in the maintainer repo (MarcoFalke) Pull request description: Moved to https://github.com/bitcoin-core/bitcoin-maintainer-tools/blob/master/optimize-pngs.py Bitcoin Core should focus on the full node implementation, not on scripts to compress png images. This script is only used when new PNG files are added to the repo. This happens about once every two years. So fetching the script from the other repo should not be a burden, but removing it from this repo is going to cut down on the meta files we need to maintain in the main repo. ACKs for top commit: practicalswift: ACK fa13090d2048c9a1e475eb25de756763f8adddb8 -- `+0 lines, -82 lines` :) promag: ACK fa13090d2048c9a1e475eb25de756763f8adddb8. hebasto: ACK fa13090d2048c9a1e475eb25de756763f8adddb8, verified that script is already [moved](https://github.com/bitcoin-core/bitcoin-maintainer-tools/pull/56). Tree-SHA512: 37d111adae769bcddc6ae88041032d5a2b8b228fec67f555c8333c38de3992f5138b30bea868d7d6d6b7f966a47133e5853134373b149ab23cba3b8b560ecb31
Diffstat (limited to 'contrib')
-rw-r--r--contrib/devtools/README.md6
-rwxr-xr-xcontrib/devtools/optimize-pngs.py76
2 files changed, 0 insertions, 82 deletions
diff --git a/contrib/devtools/README.md b/contrib/devtools/README.md
index f5533719c0..bdff7a84b0 100644
--- a/contrib/devtools/README.md
+++ b/contrib/devtools/README.md
@@ -89,12 +89,6 @@ example:
BUILDDIR=$PWD/build contrib/devtools/gen-manpages.sh
```
-optimize-pngs.py
-================
-
-A script to optimize png files in the bitcoin
-repository (requires pngcrush).
-
security-check.py and test-security-check.py
============================================
diff --git a/contrib/devtools/optimize-pngs.py b/contrib/devtools/optimize-pngs.py
deleted file mode 100755
index e9481dbbcf..0000000000
--- a/contrib/devtools/optimize-pngs.py
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/env python3
-# Copyright (c) 2014-2018 The Bitcoin Core developers
-# Distributed under the MIT software license, see the accompanying
-# file COPYING or http://www.opensource.org/licenses/mit-license.php.
-'''
-Run this script every time you change one of the png files. Using pngcrush, it will optimize the png files, 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
-'''
-import os
-import sys
-import subprocess
-import hashlib
-from PIL import Image # pip3 install Pillow
-
-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.tobytes()
- return hashlib.sha256(data).hexdigest()
-
-pngcrush = 'pngcrush'
-git = 'git'
-folders = ["src/qt/res/movies", "src/qt/res/icons", "share/pixmaps"]
-basePath = subprocess.check_output([git, 'rev-parse', '--show-toplevel'], universal_newlines=True, encoding='utf8').rstrip('\n')
-totalSaveBytes = 0
-noHashChange = True
-
-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 {}...".format(file), end =' ')
- 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)
-
- try:
- 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)
- 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, universal_newlines=True, encoding='utf8'):
- 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 {} before and after crushing don't match".format(file))
- sys.exit(1)
-
- fileMetaMap['psize'] = os.path.getsize(file_path)
- outputArray.append(fileMetaMap)
- print("done")
-
-print("summary:\n+++++++++++++++++")
-for fileDict in outputArray:
- oldHash = fileDict['sha256Old']
- newHash = fileDict['sha256New']
- totalSaveBytes += fileDict['osize'] - fileDict['psize']
- noHashChange = noHashChange and (oldHash == newHash)
- 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. Checksum stable: "+str(noHashChange)+". Total reduction: "+str(totalSaveBytes)+" bytes")