Optimize images using using WP-CLI

While working on my sister’s site https://alinelange.de/ I noticed that every image was available in 10 different formats caused by 19 different images size definitions.

I do have to say that my sister is a professional photographer who keeps blogging regularly since 2012. Throughout the years she uploaded 6000+ images. Due to the various images sizes the upload folder of her site used 10 GB storage.

To save storage, I’ve analyzed which of the defined images sizes are actually used and which one can be replaced and removed. In the first step, I set the height and width of the obsolete images to zero pixels by adding the following snippet to my functions.php:

In the next step, I deleted the obsolete images sizes one by one using the following WP-CLI calls:

While I could have skipped this step, I wanted to work on one image size at a time to be able to measure the impact of the change. After the first round of optimization the images sizes looked like this:

After checking the site to verify that no images are missing I then removed all obsolete image definitions by replacing the previous snippet with the following one:

After the second round of optimization the images sizes looked like this:

In a final step, I regenerated all images by running the following WP-CLI statement:

While it’s not much, I was able to save 300 MB of space on the server. I assume that while I’ve deleted many images, I might have also created a few variations of images that haven’t existed yet. This is the final result.

JavaScript30 – Day 19

In today’s lesson, I learned how to pipe webcam input and manipulate the stream on the fly. In comparison to the other lessons, this lesson required the use of npm. The final code can be found on Day 19 – Webcam Fun.

Resources:

30 Days of Node.js – Day 16

Compressing files plays a very important role when transferring huge amounts of data via the internet. In today’s lesson, I’ve learned how to compress and decompress text files. The code snippets can be found on https://github.com/nielslange/30-days-of-node-js/tree/master/Day%2016%20-%20Zlib%20Module.

References:

30 Days of Node.js – Day 15

Did I really miss a day yesterday? 😯 In fact, I did! I’m currently on Bali and it seems to me that the concept of time does not apply to this island. While having very intense conversations about life, I totally missed yesterday’s challenge. Nevertheless, I followed up where I left and in today’s challenge, I focused on streams. The code snippet can be found on https://github.com/nielslange/30-days-of-node-js/tree/master/Day%2015%20-%20All%20about%20streams.

Reference:

30 Days of Node.js – Day 14

Today I learned how to use Node.js in combination with Socket.IO. Within the lessons, I learned how to create two mini-applications. One application was to create quotes within an admin interface which then will be displayed in real time on another page. The second application was to dynamically change the background colour or paragraphs. Today’s code snippets can be found on https://github.com/nielslange/30-days-of-node-js/tree/master/Day%2014%20-%20Intro%20to%20socket.io.

Resources:

30 Days of Node.js – Day 13

Another day, another lesson. Today, I’ve learned how to create a signup form using Node.js, Express & MongoDB. The application uses one Node.js file and two HTML files. The code of today’s lesson can be found on https://github.com/nielslange/30-days-of-node-js/tree/master/Day%2013%20-%20Sign%20Up%20form.

References:

30 Days of Node.js – Day 12

How would applications look like if no data could be created, read, updated and deleted? That’s when Mongo DB comes into the game. Today’s lesson explained the concept of CRUD using Mongo DB. While I’m very familiar with the CRUD concept, I do have to admit that I was struggling in setting up Mongo DB initially. However, after the database was up and running, creating the code snippets was rather straightforward. Today’s code snippets can be found on https://github.com/nielslange/30-days-of-node-js/tree/master/Day%2012%20-%20CRUD%20in%20MongoDB.

Resources:

 

 

30 Days of Node.js – Day 11

Another day, another challenge. Today I’ve learned how to create a server as well as basic routing using the Node,js package Express. Today’s code snippet can be found on https://github.com/nielslange/30-days-of-node-js/tree/master/Day%2011%20-%20Express%20Framework and requires Postman to fully test it.

References:

30 Days of Node.js – Day 10

In 1981, shortly before I turned one year, the James Bond movie For your eyes only was released. Encryption and decryption was important back then and is probably even more important today. That’s why today’s lesson covered the topic Encryption & Decryption. As usual, the code snippets can be found on https://github.com/nielslange/30-days-of-node-js/tree/master/Day%2010%20-%20Encryption%20%26%20Decryption.

References: