Mallinanga
3/31/2013 - 2:27 PM

#shell Minify images

#shell Minify images

#!/bin/bash
base_path=__PATH__
if type -P jpegtran &>/dev/null; then
  echo 'Running jpegtran';
  find $base_path -iname "*.jpg" -type f -exec jpegtran -outfile '{}' -copy none -optimize -progressive '{}' \;
else
  echo 'jpegtran not found';
fi
if type -P pngcrush &>/dev/null; then
  echo 'Running pngcrush';
  find $base_path -iname "*.png" -type f -exec pngcrush -reduce -brute -nofilecheck '{}' '{}-crushed' \;
else
  echo 'pngcrush not found';
fi