Skip to content

Instantly share code, notes, and snippets.

@Phlow
Last active March 12, 2023 16:15
Show Gist options
  • Select an option

  • Save Phlow/d1e80574e7162748c2f1113acf2e78d0 to your computer and use it in GitHub Desktop.

Select an option

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.
#!/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
old_size=$(stat -f%z $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[33mNew size $new_size bytes – Saved bytes $(( ${old_size}-${new_size} ))"
echo -e "\033[0m"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment