/ server

Optimize easily your WordPress images without any plugin

You want to improve your pagespeed score by optimizing your images in WordPress ? But you don't want to pay a subscription for a plugin ? If you are using a VPS or a dedicated server, you don't need any plugin to optimize all your images easily.

For that you can use this script :

# For debian/Ubuntu
wget -qO optimize.sh https://git.virtubox.net/virtubox/wp-optimize/raw/master/deb-wp-optimize.sh && bash optimize.sh

#For Centos/RedHat
cd /var/www
wget -qO optimize.sh https://git.virtubox.net/virtubox/wp-optimize/raw/master/centos-wp-optimize.sh && bash optimize.sh

If you want to do the process manually

# Debian/Ubuntu
apt-get update && apt-get install optipng jpegoptim -y

# Centos
yum update && yum install optipng jpegoptim -y

Then you just have to go in your web directory and to run the following commands :

cd /var/www
find . -name *.jp* | xargs jpegoptim --strip-all -m76
find . -iname '*.png' -print0 | xargs -0 optipng -o7 -preserve