Last active
December 14, 2015 14:33
-
-
Save MattLoyeD/11399389 to your computer and use it in GitHub Desktop.
Image Optimizer for web (PNG & Jpg) Losslesly
This file contains hidden or 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/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