Last active
March 12, 2023 16:15
-
-
Save Phlow/d1e80574e7162748c2f1113acf2e78d0 to your computer and use it in GitHub Desktop.
Guetzli JPG/JPEG Optimizer – This little script compresses JPG-files and shows you how many bytes Guetzli saved.
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 | |
# | |
# Guetzli JPG/JPEG Optimizer | |
# This little script compresses JPG-files and shows you how | |
# many bytes Guetzli saved you in the progress. Change the | |
# variable QUALITY to change the quality of the compression. | |
# | |
clear | |
QUALITY=85 | |
echo -e "\nGuetzli starts compression with quality ${QUALITY}…\n" | |
for i in *.jpg; | |
do | |
cwebp -quiet -q 90 $i -o "${i%.*}.webp" | |
new_size=$(stat -f%z $i) | |
echo -e "\033[32mGenerate WEBP \033[33m› New size $new_size bytes – Saved bytes $(( ${old_size}-${new_size} ))" | |
old_size=$(stat -f%z $i) | |
echo -e "\033[32mMake copy for savety \033[1;32m$i \033[0;32moriginal-$i – \033[37mCopying…" | |
cp $i original-$i; | |
echo -e "\033[32mActual size of \033[1;32m$i \033[0;32m$old_size bytes – \033[37mGuetzli is working…" | |
guetzli --quality $QUALITY $i $i | |
new_size=$(stat -f%z $i) | |
echo -e "\033[33mGuetzli JPG › New size $new_size bytes – Saved bytes $(( ${old_size}-${new_size} ))" | |
echo -e "\033[0m" | |
done | |
for i in *.png; do cwebp -quiet -q 90 $i -o "${i%.*}.webp"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment