Last active
September 9, 2020 14:19
-
-
Save rama982/af3bd6fbb7378a20c3b7f5094405ddf3 to your computer and use it in GitHub Desktop.
optimize image files with PNGOUT
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 | |
# optimize image files with PNGOUT | |
# usage: bash imageopti.sh dir 4 | |
# images directory | |
DIR=$1 | |
# threads | |
N=$2 | |
for images in $DIR/* | |
do | |
( | |
# use 'Longest Match' strategy for fast process | |
pngout -s2 "$images" | |
) & | |
if [[ $(jobs -r -p | wc -l) -ge $N ]]; then | |
wait -n | |
fi | |
done | |
wait | |
# clean other file beside png | |
find $DIR -type f ! -name '*.png' -delete | |
echo "ALL DONE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment