Created
March 19, 2022 07:20
-
-
Save fotock/cb321301898667ecdb65f887ec751b90 to your computer and use it in GitHub Desktop.
Compress png and jpg.
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
PATH="$PATH:/usr/local/bin" | |
LOG=/Users/_________YOUR__HOME___DIR_____/logs/quickcompress.log | |
for f in "$@" | |
do | |
ts=$(perl -MTime::HiRes=time -e 'printf "%d\n", time*1000') | |
echo "$f begin: " >> $LOG | |
if [[ "$f" == *.png || "$f" == *.PNG ]] ; then | |
/usr/local/bin/pngquant -f -o "$f" --speed 11 "$f" >> ${LOG} 2>&1 | |
/usr/local/bin/pngcrush -ow -l 9 "$f" >> $LOG 2>&1 | |
elif [[ "$f" == *.jpg || "$f" == *.JPG || "$f" == *.jpeg ]] ; then | |
magick "$f" -quality 90 -sampling-factor 4:2:0 "$f" >> $LOG 2>&1 | |
fi | |
te=$(perl -MTime::HiRes=time -e 'printf "%d\n", time*1000') | |
tt=$(($te - $ts)) | |
echo "Time taken: $tt milliseconds" >> $LOG 2>&1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment