
WordPress
Escape the Website Relaunch with Elasticsearch for WordPress and Solr 9 for Drupal
Refined search backends deliver essential search functionality that the WordPress and Drupal communities have come to depend on.
Automate WordPress image optimization with Bash. Learn to handle thousands of images efficiently, reducing load times and boosting website performance.
As website development contractors, we sometimes come across existing Drupal or Wordpress sites that are just chock full of large, under-optimized client uploads that take forever to load in our browsers. We sometimes find our servers choking to death, not because of [insert disliked developer here]’s rogue php script, but because the server just can’t keep up with the thousands of requests for xyz image at 3000x2000 pixels, uncompressed.
Sure, we can install plugins that will re-compress images on upload, but what about all those hundreds or even thousands of images that are sitting on the server right now? Do we find another plugin to rip through the entire file base? To me, this sounds like too much work for a web stack, and really, why introduce even more load to your web server that is already choking on pixel data?
Recently, we were tasked to find a way to automate an optimization process for one of our clients’ Wordpress sites. They have around 2,500 uploads sitting on their server at the time of this writing, high res images that have all been uploaded by the client through their Wordpress media library.
Now, this normally wouldn’t be a big deal for a small number of uploads. You would just crack open an FTP client, download the suspects, open in photoshop, Save for Web and Devices, and re-upload them. But with the number of files that we were dealing with, FTP just wasn’t going to cut it, not for me anyway. A photoshop action seemed like too much work too, since I would have to manually download all the files, let photoshop run its batch (making photoshop useless while that was running), then manually upload them later.
So, I took to bash to see what I could come up with; results below. This script is meant to be run from the command line, and relies on two things:
The existence of jpegtran on your local system, which is a command found in the libjpeg library, a library that comes bundled with ImageMagick. If you’ve installed imagemagick for some other reason, you’ve already got jpegtran installed. If not, it’s just a matter of:
Ubuntu/Debian:
$ sudo apt-get install gcc
$ sudo apt-get install imagemagick
CentOS/Fedora/RHEL:
$ yum install gcc php-devel php-pear
$ yum install ImageMagick ImageMagick-devel
Mac (using homebrew):
$ brew install imagemagick
Windows:
Sorry windows users, this is bash
You’ll notice that I’ve wrapped this functionality into a bash function, and then just call the function immediately after declaration. This is for fun things like sourcing into your ~/.bash_profile. For example, remove the function call at the end of the script and save as ~/optimize_pantheon_jpgs.sh. Then add this to end of your ~/.bash_profile:
. ~/optimize_pantheon_jpgs.sh
Don’t forget the period at the beginning. Save and close, then start a new terminal session. Now, you can call optimize_pantheon_jpgs directly on the terminal from anywhere and it will return you back to where you were terminal’ed into previous to the call.

WordPress
Refined search backends deliver essential search functionality that the WordPress and Drupal communities have come to depend on.

CMS Migration
Data-driven framework for evaluating WordPress to Drupal migration. Measure baseline performance, technical limits and costs before committing budget.

CMS
Drupal vs WordPress for universities: compare security, scalability, maintenance, and governance – and see how both can be powered at scale.