Skip to content

Instantly share code, notes, and snippets.

@MattLoyeD
Last active December 14, 2015 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattLoyeD/11399389 to your computer and use it in GitHub Desktop.
Save MattLoyeD/11399389 to your computer and use it in GitHub Desktop.
Image Optimizer for web (PNG & Jpg) Losslesly
#! /bin/sh
# Usage "sh script.sh /path/to/check chmod"
# TODO : Mtime in find ...
if [ -z "$1" ]; then
DIR="`.`"
else
DIR="$1"
fi
if [ -z "$2" ]; then
CHM="755"
else
CHM="$2"
fi
find $DIR -iname '*.png' -print0 | while read i ; do
optipng -o7 -preserve -quiet "$i";
chmod $CHM "$i";
done;
find $DIR -type f -iname "*.jpg" | while read i ; do
jpegoptim --max=90 --strip-all --preserve --totals --quiet "$i";
chmod $CHM "$i";
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment