The PNG compression level is that setting in the PNG options that is set by default to 9 and that everyone keeps that way.
But what is its purpose anyway since the compression is lossless? Once decompressed the image is still the same whatever the setting? So why is it an option?
It happens that the PNG compression algorithm is quite CPU-intensive so this setting tells the algorithm how hard it should try to find things to compress. Unlike JPEG where you trade file size for image quality, in the PNG format you trade file size for CPU during export, and on big images it makes quite a difference. So lets see what happens with four different images (16Mpix each except the photo which is 14Mpx):
For instance, in the Simplex case, the final size with compression is about 20% of the uncompressed size, and for level 7 the export took about 5 times longer than the uncompressed export.
These curves make it clear that in all cases, some compression is better than no compression at all. However, past levels 4-5, there is a very substantial increase in compression time for little or no gain on the file size. In absolute numbers, given that the uncompressed export took a good half second, level 9 is nearly 18 seconds for the photo, when level 6, that produces a file which is less than 3% bigger, takes less than 4 seconds.
Choose wisely
But what is its purpose anyway since the compression is lossless? Once decompressed the image is still the same whatever the setting? So why is it an option?
It happens that the PNG compression algorithm is quite CPU-intensive so this setting tells the algorithm how hard it should try to find things to compress. Unlike JPEG where you trade file size for image quality, in the PNG format you trade file size for CPU during export, and on big images it makes quite a difference. So lets see what happens with four different images (16Mpix each except the photo which is 14Mpx):
- A plain text (8 lines in a text layer with a large font), which is expected to compress very well (PNG is designed to be efficient on computer-generate images)
- A Simplex noise which is random but with a large proportion of pure black pixels (about 50%)
- A Plasma noise which is also truly random but is made slightly less random by applying a small median blur to it.
- A photo of a gorgeous French village.
For instance, in the Simplex case, the final size with compression is about 20% of the uncompressed size, and for level 7 the export took about 5 times longer than the uncompressed export.
These curves make it clear that in all cases, some compression is better than no compression at all. However, past levels 4-5, there is a very substantial increase in compression time for little or no gain on the file size. In absolute numbers, given that the uncompressed export took a good half second, level 9 is nearly 18 seconds for the photo, when level 6, that produces a file which is less than 3% bigger, takes less than 4 seconds.
Choose wisely