Skip to content

Instantly share code, notes, and snippets.

@maliMirkec
Last active February 2, 2018 19:08
Show Gist options
  • Save maliMirkec/89cd0d2125ff3df1eb29455898f73c37 to your computer and use it in GitHub Desktop.
Save maliMirkec/89cd0d2125ff3df1eb29455898f73c37 to your computer and use it in GitHub Desktop.
Batch scripts for image optimization
http://www.tecmint.com/optimize-and-compress-jpeg-or-png-batch-images-linux-commandline/
https://blarg.co.uk/blog/recursively-optimize-png-files
# install jpegoptim
apt-get update
apt-get install jpegoptim
# install optipng
apt-get update
apt-get install optipng
cd /home/admin/web/xxx/public_html/wp-content/uploads/
find -name '*.jpg' -print0 | xargs -0 jpegoptim -f --max=80 --preserve --totals
sudo chmod 0777 -R /home/admin/web/xxx/public_html/wp-content/uploads/
sudo chown admin:admin -R /home/admin/web/xxx/public_html/wp-content/uploads/
cd /home/admin/web/xxx/public_html/wp-content/uploads/
find -name '*.png' -print0 | xargs -0 optipng -nc -nb
sudo chmod 0777 -R /home/admin/web/xxx/public_html/wp-content/uploads/
sudo chown admin:admin -R /home/admin/web/xxx/public_html/wp-content/uploads/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment