saucecontrol / PhotoSauce

MagicScaler high-performance, high-quality image processing pipeline for .NET
http://photosauce.net/
MIT License
569 stars 49 forks source link

Lossless WebP? #87

Closed amoerie closed 2 years ago

amoerie commented 2 years ago

Hi! Thanks for your absolutely amazing library. I am investigating whether this is feasible to use in a radiology viewer application, so my investigation is restricted to using lossless formats.

For my investigation, I am creating benchmarks that try out the various image formats and analyze:

I also have some unit tests that go through a single encode + decode and verify the pixel data is the same, which hopefully confirms that the encoding and decoding process is lossless.

You can follow my progress here: https://github.com/amoerie/lossless-codec-benchmarks

For now, it looks like WebP and AVIF are not lossless yet, so I am presuming I'm configuring them wrong. I also can't seem to get HEIF working, but I am also presuming an error on my part. Investigation there is ongoing.

This is my question: is it already possible to pass in WebP and AVIF encoder options so it can be set to lossless? I found a folder "Webp" under "NativeCodecs" but this only seems to implement a decoder, and is nowhere on NuGet yet.

Furthermore, if you have advice on the best parameters to use per file format for my benchmarks, I would be very eager to hear them.

Thanks and have a nice day!

P.S. Feel free to (re)use the benchmarks and tests in any way if they can be of any use to you. P.P.S. The benchmarks also include LZ4 to compare a "naive" byte array encoding with the more intelligent image formats. Sorry if that's confusing.