Google optimizer. Bash script to recursive optimize all png and .jpg

First of all install:

sudo install jpegoptim

and

sudo install optipng

nesxt make script file in your website folder

touch ./optimizer.sh
chmod +x ./optimizer.sh

next paste the code to file

nano ./optimizer.sh
#!/bin/bash
# Script Google Optimizer
# Autor: Szymon Wójtowicz
# Site: http://artmetic.pl
# Blog:  http://blog.artmetic.pl

for f in $(find ./ -name '*.png' -or -name '*.jpg'); 
do 
if [[ $f == *.png ]] ;then
optipng -strip all -o5 "$f";
elif [[ $f == *.jpg ]] ; then
jpegoptim "$f" --strip-all; 
fi
done

and run with command

./optimizer.sh

 

next check speed of your site