# Why choose anything but highest compression for PNG?

I just installed LibreOffice for the first time. In the Impress application for presentation slides, when I choose to save an image on a slide, the file type is PNG and there is a slider for compression, positioned approximately midway at 6. Internet searching reveals that PNG compression is nonlossy. Why would anyone choose anything but the highest compression?

Simply because the highest compression typically is significantly more CPU-intense (it tries out multiple different approaches to represent successive lines).

This really shouldn't make much difference on a modern PC for saving a few images. Then again, in practice, libpng seems to be pretty slow, so this might make a difference, especially for people working on older devices.

• OK. Thanks. I'll stick with the default middle-of-the-road. I can't upvote, and I need 5 minutes to accept the answer, apparently. – user2153235 Feb 1 at 22:52

Lossless or non-lossy compression is, by nature, a bijection between "a raw data" and a "compressed binary". The fundamental consequence is that it CANNOT compress every file.

In other words: suppose we consider all possible 3 MB binary files. No lossless compressor can effectively compress all files to a smaller size. There are several way to fathom this assertion.

One is to realize than you cannot fit 45 socks in 44 drawers with every sock remaining single. THere is no bijection for a finite set onto a strict subset. This concept is SO fundamental that it can be used to define infinity: a set is infinite if and only if it be in bijection to a strict subset.

Another is: suppose that you have a compressor that can reduce the size of every file. Then, if you apply it again, we could shrink the initial file, bit after bit, to a zero-sized file. Unlikely.

This means that lossless compressors have a limited range of action. Yet, a lot of nature- or man-created files (sounds, pictures) have a structure, some predictability. This depends a lot on their acquisition, etc. However, it is generally admitted that classically, you can compress files like images and sounds by a factor from $$3/2$$ to $$3-4$$ at most (we can debate other that), this is what you can get with FLAC, APE, PNG, etc.

You can achieve a better lossless compression by fine tuning prediction, packing, etc. at the price of more computations, and that other "more random" files will be inflated. But around halving the size of a file, fine tuning can improve a bit, but not that much. For a practical point of view, compressing a 3 MB by about 2, to 1.5 or 1.4 MB (6.6% imporoved) does not change your life a lot, nowadays. It used to in the past, when we had 1.44 MB floppy disks. But now, for small files, it is not a game changer. So:

Why would anyone choose anything but the highest compression? > Because this is not much difference

However, in massive data applications, where HPC and memory cost a lot (in energy, price, CO2), saving 7% more of data can be useful, or save tons of Watts, hydrocarbons or money. Using compression not only as an end-storage format, but to alleviate transmission, visualization, management, and even processing is becoming a trendy topic.

There is for instance a resurgence of lossless compression effort in HPC simulation because giga-models are becoming increasingly costly. But the challenge differs from multimedia data: there are more heterogeneous, bigger, etc. [Shameless plug: our current line of research for 3D hexaedral meshes, called HexaShrink]

I will share my experience in image optimization ... At first, I had to manually compress all the pictures through Photoshop. The most free option by the way (except for the cost of a license for Photoshop). But this process takes a lot of time if there are more than 10-20 pictures on the site. After all, each picture must be manually processed, and then upload on the site again. Tedious such a process ... Now I use the service OptixPic - It saves a lot of time) It works by itself - automatically - only 1 time it needs to be connected to the site. Google is satisfied)