PhotoSauce icon indicating copy to clipboard operation
PhotoSauce copied to clipboard

Add PhotoSauce.NativeCodecs.Mozjpeg

Open georg-jung opened this issue 1 year ago • 6 comments

Thanks for developing this great image processing pipeline!

I'm interested in compressing jpegs with a focus on storage efficiency. Thus, I created a simple .Net MozJpeg wrapper library based on pre-existing libjpeg-turbo wrappers. In the recent weeks I tried to get a deeper understanding of state-of-the-art .Net image processing and started to read parts of ImageSharp's and PhotoSauce's source code. I think it's fascinating what you and the others did both in terms of performance and thought that went into the API interface. I don't think I could neither would it make sense to compete in the context of my MozJpeg wrapper. Providing a rather thin wrapper around MozJpeg probably has its use-cases in the .Net world - from my application developer's perspective it would probably be nicer to use a more easy and complete image processing pipeline like PhotoSauce (with support for metadata copying, resizing, ...) and have MozJpeg as encoder at the end of it, though.

I've seen there already is support for libjpeg-turbo. Thus, I thought it might be not too hard to provide a packaged version of MozJpeg as an alternative that focuses more on storage efficiency than on CPU time efficiency. What do you think?

I evaluated providing a PR, but I don't think I'd get that right, given I'm not that experienced with native interop. Also I wasn't sure what this

Standard releases of libjpeg and libjpeg-turbo are not usable reliably from .NET; a custom build is required.

means.

Mozjpeg is already supported in vcpkg.

Edit: afaik MozJpeg does provide a switch to disable its size for performance trade. Thus it might even be possible to switch the backend and use that switch. I'm not sure however how accessible that switch is using the libjpeg API and if that'd be the better option overall.

georg-jung avatar Feb 15 '23 12:02 georg-jung