Skip to content

Commit

Permalink
Further tune crushinator.sh
Browse files Browse the repository at this point in the history
Use built-in facility to not overwrite existing file if
it is already optimized.
  • Loading branch information
bitwiseman committed Apr 9, 2018
1 parent bef996d commit 6c46316
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions scripts/crushinator.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env bash

FILENAME=$1
OUTPUTFILE="${FILENAME}_pngcrush_`date '+%Y%m%d%H%M'`"

if [ -z $FILENAME ]; then
if [ -z "$FILENAME" ]; then
echo "Need a filename as the first argument"
exit 1;
fi;
Expand All @@ -15,12 +14,9 @@ if [ $? -ne 0 ]; then
exit 1;
fi;


pngcrush -reduce "$FILENAME" "$OUTPUTFILE"
pngcrush -ow -noforce -reduce "$FILENAME"

if [ $? -ne 0 ]; then
echo "Error crushing ${FILENAME} to ${OUTPUTFILE}"
echo "Error crushing ${FILENAME}"
exit 1;
fi;

mv "$OUTPUTFILE" "$FILENAME"

0 comments on commit 6c46316

Please sign in to comment.