Skip to content

Instantly share code, notes, and snippets.

@Phlow
Last active March 12, 2023 16:15
Show Gist options
  • Save Phlow/d1e80574e7162748c2f1113acf2e78d0 to your computer and use it in GitHub Desktop.
Save Phlow/d1e80574e7162748c2f1113acf2e78d0 to your computer and use it in GitHub Desktop.

Revisions

  1. Phlow revised this gist Mar 12, 2023. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions guetzli-optimizer.sh
    Original file line number Diff line number Diff line change
    @@ -11,10 +11,17 @@ 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[33mNew size $new_size bytes – Saved bytes $(( ${old_size}-${new_size} ))"
    echo -e "\033[33mGuetzli JPG › New size $new_size bytes – Saved bytes $(( ${old_size}-${new_size} ))"
    echo -e "\033[0m"
    done
    done

    for i in *.png; do cwebp -quiet -q 90 $i -o "${i%.*}.webp"; done
  2. Phlow created this gist Feb 14, 2018.
    20 changes: 20 additions & 0 deletions guetzli-optimizer.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/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