Skip to content

Instantly share code, notes, and snippets.

@mklooss
Last active September 26, 2017 07:29
Show Gist options
  • Save mklooss/6275befeaf6024d83cec to your computer and use it in GitHub Desktop.
Save mklooss/6275befeaf6024d83cec to your computer and use it in GitHub Desktop.
optipng / jpegoptim
#!/bin/bash
# combine mozjpeg and jpegoptim
# you have to build https://github.com/mozilla/mozjpeg first
# path = /opt/mozjpeg
# ~# find . -iname "*.jp*g" -type f -exec jpegcompress "{}" \;
if [ -z "$1" ]; then
echo "is empty"
exit;
fi
export PATH=/opt/mozjpeg/bin/:$PATH
export LD_LIBRARY_PATH=/opt/mozjpeg/lib:$LD_LIBRARY_PATH
jpegtran -copy none -optimize -progressive -outfile "$@" "$@"
jpegoptim -o --strip-all --max=90 --all-progressive "$@"
#!/bin/bash
#JPEG
find . -iname "*.jp*g" -type f -exec jpegoptim -o --strip-all --max=90 --all-progressive "{}" \;
#PNG
find . -iname "*.png" -type f -exec optipng -o9 -strip all "{}" \;
@DevertNet
Copy link

For PNGs add "-strip all":
find . -iname "*.png" -type f -exec optipng -o9 -strip all "{}" \;

@mklooss
Copy link
Author

mklooss commented Jul 17, 2017

added :)

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