Skip to content

Instantly share code, notes, and snippets.

@Mallinanga
Created March 31, 2013 14:27
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 Mallinanga/5280748 to your computer and use it in GitHub Desktop.
Save Mallinanga/5280748 to your computer and use it in GitHub Desktop.
#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment