Skip to content

Instantly share code, notes, and snippets.

@peterfarrell
Last active August 29, 2015 14:10
Show Gist options
  • Save peterfarrell/bbce4d8f2c2f444980f5 to your computer and use it in GitHub Desktop.
Save peterfarrell/bbce4d8f2c2f444980f5 to your computer and use it in GitHub Desktop.
Crush / compress - jpg and png bash file
crush() {
for f in *;
do
mv "$f" `echo $f | tr ' ' '_'`
done
for f in *.png
do
echo "$f"
pngcrush -brute "$f"{,.} && du -b "$f"{,.}
cp -f "$f." "$f"
done
for f in *.jpg
do
echo "$f"
jpegtran "$f" > "$f." && du -b "$f"{,.}
cp -f "$f." "$f"
done
}
@peterfarrell
Copy link
Author

You need to install pngcrush and libjpeg-comps (for jpegtran) on your system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment