Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced compression controls #502

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Shnatsel
Copy link
Contributor

@Shnatsel Shnatsel commented Sep 24, 2024

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 match imagemagick'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 to PartialInfo and back will reset the compression field since it gets lowered to the advanced representation now, and that field is public. If that's an issue, I can make PartialInfo preserve the original compression setting.

@Shnatsel
Copy link
Contributor Author

PR for a nicer high-level API I mentioned in the description is now up: #503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Enabling uncompressed PNG support
1 participant