After running a regeneration of my images (due to changing things on my theme) my Gtmetrix score dropped from an A to a D! In looking at why, I saw it was telling me my images should be optimized.

Best to get on that, eh?

The easiest way is to install jpegoptim on the server:

$ yum install jpegoptim

And then to run a compression on my images:

$ jpegoptim IMAGE.jpg

Anyone fancy running that on a few thousand images? Hell no. We have a couple options here. One is to go into each folder and run this:

$ jpegoptim *.jpeg *.jpg

The other is to sit in the image root folder and run this:

$ find . -type f -name '*.jp?g' -exec jpegoptim {} --strip-all \;

I picked --strip-all since that removes all the image meta data. While I would never want to consider that on a photoblog, I needed to compress everything and, for some reason, unless I stripped that data I didn’t get smaller sizes. For this case, it wasn’t an issue.

What about PNGs? Use optipng ($ yum install optipng) and run this:

$ find . -type f -name '*.png' -exec optipng *.png \;

Going forward, I used Homebrew to install those locally and compress my images better, though I’m usually pretty good about remember that part. Well. I thought I was.

Reader Interactions


  1. Hi!
    Lots of WordPress folks are on shared servers and or just need something that makes it easy to optimize their images. I’ve been using the EWWW Image Optimizer plugin on my clients’ site to great effect.
    Besides compressing and optimizing, you can also set a maximum image size – You don’t need to be concerned with bloating your Uploads folder with unnecessarily huge files.
    Just wanted to pass that along…

    • I actually don’t like EWWWW on shared servers. When you’re resizing images, the place for it is your laptop, not your server. Shared hosts have limits on services and processes, and image processing will hit that faster than just about anything else :/

%d bloggers like this: