Created
May 29, 2012 21:24
-
-
Save daogurtsov/2830799 to your computer and use it in GitHub Desktop.
Minify png and jpeg
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
| for file in `find . -iname "*.jpg" -or -iname "*.png" -or -iname "*.jpeg"`;do | |
| ext=${file##*.} | |
| if [ -n "$ext" ]; then | |
| if [ "$ext" = "jpg" ]; then | |
| echo "optimizing ${file} as jpeg file with jpegtran" | |
| jpegtran -copy none -optimize -perfect -outfile temp_abracadabra_filename.jpg $file | |
| mv -f temp_abracadabra_filename.jpg $file; | |
| fi | |
| if [ "$ext" = "jpeg" ]; then | |
| echo "optimizing ${file} as jpeg file with jpegtran" | |
| jpegtran -copy none -optimize -perfect -outfile temp_abracadabra_filename.jpeg $file | |
| mv -f temp_abracadabra_filename.jpeg $file; | |
| fi | |
| if [ "$ext" = "png" ]; then | |
| echo "optimizing ${file} as png file with pngcrush" | |
| pngcrush -rem alla -reduce -brute "$file" temp_abracadabra_filename.png; | |
| mv -f temp_abracadabra_filename.png $file; | |
| fi | |
| fi | |
| done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment