Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Exposes advanced DEFLATE compression options. Supersedes #488, fixes #349.
Also adds an option for store-only compression, like #490, but without a semver break.
Expands roundtrip tests to cover more compression modes.
Motivation
I am going to need this in
wondermagick
. I'll have to roughly matchimagemagick
's own compression levels using controls over both filters and DEFLATE compression level.Why this API?
The API we have right now is a mix of high-level and low-level concepts. We only have a limited selection of DEFLATE compression levels, but also expose the full complexity of filter selection to the user without any heuristics and requiring the user deal with it.
Ideally we'd expose a high-level API with a few simple presets that take care of both DEFLATE and filtering, plus a separate low-level API that exposes the full complexity of DEFLATE and filtering options for users who do need it, such as
wondermagick
.Evolving
Compression
to set the filter as well is an API break, but we can add the low-level API in a semver-compatible way, which is what this PR does.Semver and longevity
This API it can be easily evolved later: new modes can be easily added since the enum is marked
#[non_exhaustive]
, and removed modes can be marked#[deprecated]
and mapped to the closest thing we do have.The only observable change in behavior is converting from
Info
toPartialInfo
and back will reset thecompression
field since it gets lowered to the advanced representation now, and that field is public. If that's an issue, I can makePartialInfo
preserve the original compression setting.