Optimize all images within current directory

Posted in Web Development on 06.10.2015 by @chasebadkids

When trying to get that A rating with Google Page Speed or GTMetrix, one of the easiest ways to earn points is through the optimization of all the PNG and JPG images within your web root.  I tend to use optipng and jpegoptim for this.  It gives the ability to easily lossless optimize all your images so that you make search engines and your users happy with fast sites, while still showing them good looking images.

Follow these instructions and you’re on your way to having an even faster site.

Step 1)  SSH to your system

Step 2) CD to directory where your images exist ( This will vary on each hosting environment )

Step 3)  Run the optimization scripts

What the above does, is searches everywhere within your current directory and down, for jpeg and PNG images.  Once it finds them it will optimize them and replace the larger image right in place.

Keep in mind, that this script can take minutes or even hours depending on how many images you have and how fast your server is, so your best bet is to fire this off and leave it for a while.

And that’s it!  You’re on your way to having a faster WordPress site with optimized images.