Make PNG compression level configurable
When exporting to PNG format, the PNG compression step can take several times longer than the processing of the image itself, depending on the hardware setup. This is caused by darktable instructing libpng to use the Z_BEST_COMPRESSION level, which is equal to compression level 9. Level 9 doesn't result in much smaller output files than level 5, but needs much more CPU cycles. libpng uses libz to do the actual compression, which only runs in a single-threaded fashion, making the issue even worse.
My PC has a six-core AMD Ryzen CPU and a NVIDIA GTX 950 GPU, and I have enabled both OpenMP and OpenCL. If I activate darktable's internal profiling, I can see that a typical Nikon D750 RAW image with my usual settings is processed in less than a second, but then the CPU spends another ten seconds compressing the output on a single core. If I set the compression level to 5 instead, the same system easily processes and exports a single picture in two seconds.
The attached patch adds a "Compression" slider to the PNG imageio module user interface, making the compression level configurable, and sets the default compression level to 5.
#3 Updated by Simon Raffeiner over 1 year ago
Thanks! I didn't know how to handle the module versioning stuff, but I thought a working patch for the feature itself would speed things up, so I attached it. Next time I hopefully know what additional stuff to look for.
Please credit me as Simon Raffeiner <firstname.lastname@example.org>, yes.