Google open source image compression algorithm Guetzli measured experience report

Author | Edited by Wang Yajun | Song Bingjin

Wang Yajun, Tencent engineer, responsible for business operation and maintenance of OMG wireless news, Tencent video and picture services, etc.

To read the original text , for more technical dry goods, please visit Tengyun Pavilion .


Google has released new open source technology again. This time, the JPEG format image is re-encoded with a new algorithm. The output image is still JPEG, but the size of the image is significantly reduced, and the quality is not only not lost, but even more optimized. Come and experience it quickly. Bundle.

1. Environment installation

Download Google open source software, compile and install it is actually a bin tool. Input image, output jpeg format image.

Project address: https://github.com/google/guetzli

Below the document is written the installation method of Ubuntu, Arch Linux, windows, macOS. We take Ubuntu system as an example to introduce how to install guetzli.

First, clone Google's project file:

git clone https://github.com/google/guetzli.git

Then, install the libpng package:

sudo apt-get install libpng-dev
cd guetzli

Then directly ,make generate the bin file, and a powerful open source tool is generated../bin/Release/guetzli

Second, the actual test

The use of guetzli is relatively simple, with few parameters. The default quality is 95. You can also use -qualityto specify a quality greater than or equal to 84. If it is less than 84, you need to modify the source code. The input must be a picture that meets the conversion requirements, and the output is a jpeg format picture.

What is an eligible image?

Official description:

Only YUV color space input jpeg is supported

The actual measurement found that png images using transparent channels, non-YUV jpegs such as black and white images, and gif images cannot be converted .

How does guetzli work?

Measured 1292 images in batches. Use the default parameters, which is 95% of the quality of the original image.

1185 images were successfully converted, accounting for 91.7%, of which 3 png images were larger than the original image after converting to jpeg, accounting for 0.2%. 107 cannot be converted, accounting for 8.3%.

The average size of the original image is 33KB, 23.4KB after guetzli compression, the average compression rate is 29%, and the average time per image is 7956 milliseconds.

The largest single image is 3.76MB, 2.55MB after guetzli compression, the compression rate is 31.5%, and it takes 976949 milliseconds (16 minutes).

The smallest single picture is 757B, 603B after guetzli compression, the compression rate is 20%, and it takes 65 milliseconds.

In addition, borrow the comparison pictures used in foreign media reports to intuitively feel the effect of compression:

The left is the original image, the middle is compressed with libjpeg, and the right is compressed with guetzli.

How is the resource consumption of guetzli?

Official documents say that 1MPIX image processing needs to consume 300M of memory.

Measured a 1MB size 1920x2560 picture, with 4.9MPIX. The theoretical memory consumption is 1474MB, and the actual memory consumption is 1009MB, which is basically consistent with the theory. It can be seen that this tool is a big memory consumer. 60G memory is only enough to process 200MPIX, that is, it can process about 40 1920x2560 pictures at the same time.

CPU consumption is always 100% single-core occupancy. Of course, the actual use of multi-core machines can run multiple processes at the same time. There are as many guetzli tasks as there are cores.

The time-consuming of compressing an image is related to the discrete size of the image. The larger the image, the longer the time-consuming:

The test environment uses a machine with 8 cores and 16G memory. It takes about 8 seconds for a single core to process a 23KB image on average, which takes a long time and is destined to be impossible to perform online real-time compression.

3. Comparison of advantages and disadvantages

What are the advantages of guetzli?

For jpg images with a quality of 90 or below, the quality of the new images output by guetzli will not be reduced. The actual compression rate can reach an average compression rate of 29%.

The compatibility is relatively good, and the output jpeg format pictures are very versatile . There is no protocol incompatibility like webp and sharpp.

The image encoding and decoding speed in jpeg format on the client side is much faster than other proprietary protocols.

What are the disadvantages of guetzli?

guetzli handles type limitations and cannot handle all types of images. Only YUV color-coded pictures can be processed .

The timeliness is poor, and the larger the picture, the slower the processing . It takes 291 seconds to process a 1MB image, and an average of 8 seconds for a 23KB image in this test.


related suggestion:

  1. Image traffic saving killer: CDN-based sharpP adaptive image technology practice
  2. Whimsical ideas about slimming down Android image resources
  3. Laravel integrates Wanxiang Youtu image management capabilities to create efficient image processing services

To read the original text , for more technical dry goods, please visit Tengyun Pavilion .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324402044&siteId=291194637