Skip to content

Instantly share code, notes, and snippets.

@rama982
Last active September 9, 2020 14:19
Show Gist options
  • Save rama982/af3bd6fbb7378a20c3b7f5094405ddf3 to your computer and use it in GitHub Desktop.
Save rama982/af3bd6fbb7378a20c3b7f5094405ddf3 to your computer and use it in GitHub Desktop.
optimize image files with PNGOUT
#/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