Created
November 16, 2013 05:22
-
-
Save patrickkettner/7496302 to your computer and use it in GitHub Desktop.
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/bash | |
ASSET_PATH=$1 | |
t="$(date +%s)" | |
if [ ! -d $ASSET_PATH ] && ( echo $ASSET_PATH not found && exit 1 ) | |
hash zopfli 2>/dev/null || (echo zopfli needs to be installed && exit 1) | |
find $ASSET_PATH -type f | xargs -P 99 zopfli | |
# Remove any compressed file that was actually larger than the original | |
for FILE in $(find $ASSET_PATH -name *.gz ); do | |
if [ $( stat -c%s $FILE) -ge $( stat -c%s ${FILE%.*}) ]; then | |
rm $FILE | |
fi; | |
done; | |
t="$(($(date +%s)-t))" | |
echo "time in seconds: ${t}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment