Last active
June 15, 2017 12:28
-
-
Save NickJian/ba13f55373791983b3cdf71377b6a6a4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
while [[ true ]]; do | |
echo "pull latest images" | |
git clone <git path> --branch <branch name> --single-branch | |
# step1, run imageOtim | |
./imageoptim -s -d ./<res path> | |
# step2, convert webp | |
# webp is not supported until 4.3 (api 18) | |
# echo "locate all image files" | |
# find . -path "./<res path>/*" -type f \( -iname "*.png" -o -iname "*.PNG" -o -iname "*.jpg" -o -iname "*.JPG" \) -print0 | while IFS= read -r -d $'\0' file; | |
# do | |
# base="${file:0:${#file}-4}" | |
# webpfile="${file:0:${#file}-4}.webp" | |
# | |
# if ! [[ $file == *".9"* ]] && [[ $file == *".png"* ]] | |
# then | |
# echo | |
# cwebp -q 70 "$file" -o "$webpfile" -m 6 -quiet | |
# | |
# I=$(stat -f "%z" $webpfile) | |
# J=$(stat -f "%z" $file) | |
# | |
# echo "convert $file to webp (webp size:" $I " original size:" $J ")" | |
# | |
# # delete the WebP file if it is equal size or larger than the original PNG | |
# if [ $I -gt $J ] | |
# then | |
# echo "delete WebP file that is no smaller than PNG" | |
# rm -f "$base".webp | |
# else | |
# echo "replace png with smaller webp" | |
# rm -f "$file" | |
# fi | |
# fi | |
# done | |
# | |
echo "push image changes..." | |
git add -A | |
git commit -am "weekly image triming" | |
git push origin <branch name> | |
cd .. | |
echo "job done, see you next week" | |
sleep 604800 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment