girder / large_image

Python modules to work with large multiresolution images.
http://girder.github.io/large_image/
Apache License 2.0
192 stars 43 forks source link

Abstract output format compression options #900

Open manthey opened 2 years ago

manthey commented 2 years ago

We currently support some specific compression options (jpegQuality, jpegSubsampling, tiffCompression). If we want to support more output formats (e.g., #899), it'd be nice to abstract this to format independent values. For example, values might be "quality" (0-poor, 100-good), "lossless" (boolean), "mode" (internal mode value like lzw), "level" (0-fast, 100-slow and better).

I image a table with the known formats and a list of lambda that convert from the abstract properties to the format-specific properties for PIL. This would also be a good point to use other compression libraries (e.g., a wrapper around another PNG library would be faster than PIL).

manthey commented 2 years ago

One drawback to the sample values I listed is that it reduces specific tuning of formats (jpegSubsampling being the obvious example). The alternative is a generalized dictionary of encoder options, but then the caller needs to know specifics of which library is doing the encoding.