feat(best-format): Support best format#17
Merged
nakamuraos merged 9 commits intomainfrom Mar 31, 2026
Merged
Conversation
…ulti-encode selection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces a new "best format" selection feature for image output, allowing the system to automatically choose the most efficient image format based on content and configuration. It adds support for the
format=bestoption, exposes several new environment variables for fine-tuning the behavior, and updates the configuration, parsing, and service layers accordingly. Documentation and tests have also been updated to reflect these changes.Best format selection feature:
format=bestin image requests, enabling automatic multi-format encoding and selection of the smallest result. The list of candidate formats is configurable and lossless formats are included/excluded based on image complexity. [1] [2] [3]BEST_FORMAT_COMPLEXITY_THRESHOLD,BEST_FORMAT_MAX_RESOLUTION,BEST_FORMAT_BY_DEFAULT,BEST_FORMAT_ALLOW_SKIPS,BEST_FORMAT_PREFERRED_FORMATS) to control best format selection, with corresponding logic to parse and apply these settings. [1] [2] [3] [4] [5]Configuration and service integration:
Configurationstruct and related logic to include aBestFormatConfigsection, ensuring all services and tests construct and use the new configuration. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Proxy and pipeline logic:
format=bestis requested or when theBEST_FORMAT_BY_DEFAULTsetting is enabled and no format is specified. [1] [2]TransformParamsto distinguish between format-only transforms and those requiring re-encoding, supporting theBEST_FORMAT_ALLOW_SKIPSoptimization.Documentation and tests:
README.md,.env.sample) to describe the new feature, its configuration options, and usage. [1] [2] [3]These changes collectively enable flexible, automatic selection of the optimal image format for each request, with robust configuration and clear documentation.