Skip to content

Instantly share code, notes, and snippets.

@thinkingcap
Created March 18, 2017 11:08
Show Gist options
  • Save thinkingcap/0ba2a1ed631500900ae5f9540f818f94 to your computer and use it in GitHub Desktop.
Save thinkingcap/0ba2a1ed631500900ae5f9540f818f94 to your computer and use it in GitHub Desktop.
#! /bin/sh
# Usage A:
# optimise-images.sh /path/dir
#
# Usage B:
# cd /images/dir
# optimise-images.sh
EXT="jpe?g"
if [ -z "$1" ]; then
DIR="`pwd`"
else
DIR="$1"
fi
# Optimize JPEG images that are over 200k
find "$DIR" -regextype posix-egrep -regex ".*\.($EXT)\$" -type f -size +200k | xargs -I{} guetzli -quality 90 "{}" "{}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment