Skip to content

Instantly share code, notes, and snippets.

@jprieton
Last active October 18, 2019 15:52
Show Gist options
  • Save jprieton/cb3af6edb0451792debc7806555a34f9 to your computer and use it in GitHub Desktop.
Save jprieton/cb3af6edb0451792debc7806555a34f9 to your computer and use it in GitHub Desktop.
Image optimization
#!/bin/sh
# find /var/www/html/wp-content/uploads/ -type f -empty -iname "*.jpg" -delete
# find /var/www/html/wp-content/uploads/ -type f -empty -iname "*.jpeg" -delete
# find /var/www/html/wp-content/uploads/ -type f -empty -iname "*.png" -delete
#
# find /var/www/html/wp-content/uploads/ -type f -iname "*.jpg" -exec jpegoptim --strip-all {} \;
# find /var/www/html/wp-content/uploads/ -type f -iname "*.jpeg" -exec jpegoptim --strip-all {} \;
# find /var/www/html/wp-content/uploads/ -type f -iname "*.png" -exec optipng {} \;
#
# http://www.kokkonen.net/tjko/src/man/jpegoptim.txt
find /var/www/html/wp-content/uploads/ -type f -iname "*.jpg" | xargs jpegoptim -p -m70 --all-progressive --strip-all
find /var/www/html/wp-content/uploads/ -type f -iname "*.jpeg" | xargs jpegoptim -p -m70 --all-progressive --strip-all
# http://optipng.sourceforge.net/
find /var/www/html/wp-content/uploads/ -type f -iname "*.png" | xargs optipng -o7 -strip all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment