Skip to content

Instantly share code, notes, and snippets.

@tuanhaviet22
Created May 11, 2021 04:18
Show Gist options
  • Save tuanhaviet22/829cae381c959fd9f46c3b8ec7d46953 to your computer and use it in GitHub Desktop.
Save tuanhaviet22/829cae381c959fd9f46c3b8ec7d46953 to your computer and use it in GitHub Desktop.
Useful command optimize image
#Use two package jpegotpim & optipng to optimize image
aptitude install jpegoptim optipng
find . -type f -regex ".*\.jpe?g" -exec jpegoptim --strip-all {} \;
find . -type f -name "*.png" -exec optipng {} \;
#Bash file for cron
#Create current path
DIR=$PWD"/public/"
find $DIR -type f -regex ".*\.jpe?g" -ctime -1 -exec jpegoptim --max=90 --strip-all {} \;
find $DIR -type f -name "*.png" -ctime -1 -exec optipng -o5 {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment