Created
October 5, 2017 14:06
-
-
Save mikoim/5a6e80443b7b5fb1d2a98c488bc41ce9 to your computer and use it in GitHub Desktop.
Optimize all png files in history of repository with "git filter-branch" command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
FILENAME="$1" | |
HASH=$(md5sum "${FILENAME}") | |
HIT=$(grep -c "${HASH}" /tmp/hash.txt) | |
echo "${FILENAME}" | |
if [ "${HIT}" -eq 0 ];then | |
optipng -o7 -clobber "${FILENAME}" | |
HASH=$(md5sum "${FILENAME}") | |
echo "${HASH}" >> /tmp/hash.txt | |
else | |
echo "SKIP" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
CMD="find . -iname '*\.png' -type f -print0 | xargs -0 -L 1 -P 4 --no-run-if-empty /tmp/optimize.sh" | |
git filter-branch --prune-empty --tree-filter "${CMD}" --force HEAD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment