How To Optimize Site Images Using the Image Optimizer Package for WP-CLI

Reading Time: 2 minutes

There will be many times when you will need to optimize all images in a site media library. If you are familiar with using WP-CLI, then there is a very handy package which can be installed. The package is called “image-optimize” and it will simplify the process of getting your images ready for web hosting.

This package is not for “managed hosts” since the libraries needed will not be able to be installed having without root access and it can be CPU resource intensive.

Preparing to Run Commands

The package for WP-CLI is called image-optimize. To be able to use this package, you will need to login to your site’s server and update WP-CLI. You can update WP-CLI by running the following command:

wp cli update

Next, you will need to install a number of libraries that the package uses to optimizes jpeg, png and gif images with these commands:

sudo apt-get install jpegoptim
sudo apt-get install optipng
sudo apt-get install pngquant
sudo apt-get install gifsicle

Now you can install the stable version of the image-optimize package with this command:

wp package install typisttech/image-optimize-command:@stable

Optimizing Site Images

The following are examples of the commands to run after a WordPress core update:

wp image-optimize mu-plugins
wp image-optimize plugins
wp image-optimize themes
wp image-optimize wp-admin
wp image-optimize wp-includes

You can use this command to regenerate all thumbnails on a site.

wp media regenerate --yes
You may need to limit how many images that image-optimize will process in a single back. To limit the batch size,  you just need to add the –limit flag to the end of the batch command and specify the amount, as shown in these examples:

wp image-optimize batch --limit=500
wp image-optimize batch --limit=1000
wp image-optimize batch --limit=2500
wp image-optimize batch --limit=5000

When using the image-optimize WP-CLI command, server CPU usage may be intensive, so run the batch commands in smaller sizes during the off hours times on your site. You can track CPU usage whilst running a batch optimize command by using htop. You can install and run htop using the following commands:

sudo apt-get install htop
htop

To use htop to monitor server load, keep a terminal window open while the batch optimize command is running in another terminal window. In our testing, the CPU usage was not too high.

1.61GB/3.74GB Memory usage
180M - 3.86GB Swap

Restoring Optimized Images

Before images are optimized backup versions are created, which means that you can restore at any time to a backup file and replace out the optimized version.

For example, Attachment 123 was optimized using this command:
wp image-optimize attachment 123

To restore the attachment for 123 the command to run would be:
wp image-optimize restore 123

You can use the wp media regenerate command to regenerate a specific media file.
wp media regenerate 123

 

Being able to  optimize the images in your WordPress sites media library will reduce the amount of storage needed for your site. Optimization will also improve the speed and performance of your site for visitors, improving user experience and satisfaction.

How To Install Docker on Ubuntu 16.04

Reading Time: 7 minutes

Adding Docker to an Ubuntu server.

Docker is an open-source software tool designed to automate and ease the process of creating, packaging, and deploying applications using an environment called a container. The use of Linux containers to deploy applications is called containerization. A Container allows us to package an application with all of the parts needed to run an application (code, system tools, logs, libraries, configuration settings and other dependencies) and sends it out as a single standalone package deployable via Ubuntu (in this case 16.04 LTS). Docker can be installed on other platforms as well. Currently, the Docker software is maintained by the Docker community and Docker Inc. Check out the official documentation to find more specifics on Docker. Docker Terms and Concepts. Continue reading “How To Install Docker on Ubuntu 16.04”

What is a progressive JPEG?

Reading Time: 2 minutes

The JPEG image format is one of the most commonly used image formats on the web. The format is most often used for colorful, complex images such as photographs. The JPEG specification includes a range of valid file extensions, however the most common are .jpg and .jpeg.

No matter the extension used all JPEG images will be treated more or less the same. Although not all JPEG images are created equally. In the image formats specification there exists a lesser known setting. This setting, called Progressive Mode, can drastically improve the experience using JPEGs on the web. Continue reading “What is a progressive JPEG?”

Featured Video: Liquid Web Managed WordPress and Image Compression

Reading Time: < 1 minute

The key to running a successful blog or website is having great content and making it easy for your users to find what they need. Part of providing great blog content usually involves using images and graphics to enhance your articles, posts and pages. Doing so will provide your readers with visual context and can help break up large blocks of text. Using lots of visual elements and images isn’t without its trade-off though.

The more HD photos you use, the more data a user has to download when reading your articles. This can mean longer load times for users, and higher disk and bandwidth usage for your server. That’s why you should always optimize your website’s images since long page loads can cost you views. In this featured video Chris Lema shows how our Managed WordPress improves this with a default plugin. Continue reading “Featured Video: Liquid Web Managed WordPress and Image Compression”

Proactive Server Maintenance Checklist, Prior to Reboot

Reading Time: < 1 minute
Take a Backup, or Be Sure Backups are Running

We have tutorials on How to Create a Storm Server Backup, and How to Restore a Storm Server Backup.

Check Running Processes

Liquid Web’s Heroic Support team closely monitors the load on your servers with Sonar® proactive monitoring and service restoration. That said, it’s always wise to glance at what processes are running on your server to assure your services are running as expected. Check-out our tutorial on Monitoring Server Processes with Top for Linux.

Verify Services Will Start at Boot

Be sure to verify that all of your necessary services are configured to start when the server boots up. For CentOS users, you can follow this tutorial: chkconfig Command Examples for Red Hat and CentOS.

Save, Save, and Save Some More

Always check whether or not there are any unsaved changes to configuration files, etc. prior to a reboot. Save early and safe often!
Continue reading “Proactive Server Maintenance Checklist, Prior to Reboot”