📜 ⬆️ ⬇️

Evaluate the effectiveness of Guetzli - optimization time and compression ratio


Images contribute the most to web page size. According to many experts, the optimization of images, their compression is the number one priority in the list of activities to accelerate the performance of sites. For this, various compression methods can be used - lossy or lossless, as well as conversion to other formats - SVG or WebP.

Since the theme of image optimization is still relevant, Google recently introduced a new open source image compression algorithm called Guetzli. In this article we will understand what it is, how it works and compare its performance with other widely used image compression algorithms.

What is Guetzli?



Guetzli is a “cookie” of the German-speaking Swiss, a new JPEG image compression algorithm promoted by Google. According to Google, Guetzli compresses images up to 35% more efficiently than other algorithms currently known. Guetzli is similar to Google’s other algorithm, Zopfli, and also does not require users to change file formats.
')
To demonstrate the difference between the compression results of the Guetzli algorithm and the commonly used libjpeg, Google gives the following picture:


On the left - the original image, in the center - compressed using libjpeg, on the right - Guetzli. As you can see, there are actually fewer artifacts on the processed Guetzli image.

And now Google says it’s possible to achieve smaller images without significant loss of quality, but the problem with Guetzli is that it takes much longer to process the image, and besides, it does not create progressive JPEG. This may be crucial for you when choosing an image encoder, or it may not be, but in any case - below we have cited some of the characteristics of the new encoder in comparison with the well-known and widely used ones.

How to compress images using Guetzli?


Before delving into the comparison, we will discuss how to use this algorithm for your purposes. This can be done in several ways:


Depending on your needs, the installation process may vary. For the purpose of this article, Guetzli was installed using Homebrew according to the instructions for installation on Mac OS located on GitHub.

  1. Install Homebrew
  2. Enter brew install guetzli

Guetzli versus Lossy Compression and WebP


The tests described below illustrate the difference in compression time and the final file size for Guetzli, lossy compression, and with the WebP format. For all cases, the quality parameter was set to 85. The snippet for encoding with Guetzli looked like this:

 time guetzli --quality 85 --verbose imagename.jpg output.jpg 

It should be noted that the quality parameter of Guetzli cannot be lower than 84, so if you need even more compression, you need to take another tool. Quality parameter 85 was chosen according to Google JPEG compression guidelines.

Reduce quality to 85 if it is higher. A higher quality setting leads to a rapid increase in file sizes, but the visual quality changes little.

The Optimus developer API was used for lossy compression and WebP format. To test the algorithms, we took 4 images:

FileThe sizeGuetzliLossyWebp
test-1.jpg712 Kb67 Kb / 38.30 s83 Kb / 2s53 Kb / 3c
test-2.jpg1.7 MB231 Kb / 81s238 Kb / 4s254 Kb / 3s
test-3.jpg2.2 MB346 Kb / 150s416 Kb / 4s344 Kb / 4s
test-4.jpg4.6 MB478 Kb / 286 s499 Kb / 5s322 Kb / 5s

As can be seen from the results, the winner is WebP in both compression speed and file size. With the exception of image number 2.

The average time to optimize these images with Guetzli was 2 minutes 31 seconds. Since Guetzli squeezes more efficiently than lossy compression, it seems to be clear that it must spend more time on it. But WebP compresses even more efficiently, and works ten times faster. But WebP changes the image format, which is not always acceptable.

Pros and Cons Guetzli


Based on the test results and on what features are built into Guetzli, it can be said that the new encoder has both advantages and disadvantages. On the one hand, it actually encodes better than many other libraries, on the other hand, it requires an incomparably longer time.

Behind



Vs



Summary


Everything is bad. Guetzli creates smaller files than most other encoders. In addition, the files compressed with this algorithm have a much higher visual quality. But the big problem is the time spent on image processing. If time is not a crucial parameter for you, then Guetzli would be a good option.

On the other hand, tests show that WebP creates smaller files and spends tens of times less time on it. Yes, it is not supported by all browsers, this is a minus, but there are ways to get around this problem. In particular, some WordPress plug-ins give out to browsers that do not support WebP original PNG or JPEG images.

Source: https://habr.com/ru/post/329766/


All Articles