Оптимизация изображений на хостинге
Скрипт для оптимизации изображений по рекомендации Google PageSpeed Insights:
## Settings ##
# Image folder
image_path="/var/www/path-to-site-or-image-folder/"
## find and process images from prev cron ##
## Process files in image_path which have been modified in the last twenty-four hours ##
# Process png, gif, bmp, tiff images
nice -n 19 find $image_path \( -iname "*.png" -o -iname "*.gif" -o -iname "*.bmp" -o -iname "*.tiff" \) -mime 0 -exec optipng -o7 '{}' \;
# Process jpeg and jpeg images
nice -n 19 find $image_path \( -iname "*.jpg" -o -iname "*.jpeg" \) -mtime 0 -exec jpegoptim '{}'