-
Notifications
You must be signed in to change notification settings - Fork 2
Correct quality precedence and cache-hit header consistency #70
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,7 +247,12 @@ fn metadata_keep(options: &SaveOptions) -> String { | |
| // A gain map is what makes an HDR image high dynamic range; it is neither | ||
| // descriptive metadata nor a colour profile, so neither strip option should | ||
| // take it away when the request explicitly asked to preserve it. | ||
| if options.preserve_hdr.unwrap_or(false) { | ||
| // | ||
| // The flag itself only exists from libvips 8.16. Naming it on an older | ||
| // build makes the option-string parser reject the whole encode, so a | ||
| // deployment linked against an older system libvips would fail every | ||
| // request that set preserve_hdr rather than merely losing the gain map. | ||
| if options.preserve_hdr.unwrap_or(false) && supports_gainmap_flag() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When running against libvips older than 8.16, this now returns successfully while omitting the gain map, but Useful? React with 👍 / 👎. |
||
| flags.push("gainmap"); | ||
| } | ||
|
|
||
|
|
@@ -258,6 +263,20 @@ fn metadata_keep(options: &SaveOptions) -> String { | |
| } | ||
| } | ||
|
|
||
| /// Whether this libvips knows the `gainmap` metadata flag, added in 8.16. | ||
| fn supports_gainmap_flag() -> bool { | ||
| static SUPPORTED: OnceLock<bool> = OnceLock::new(); | ||
| *SUPPORTED.get_or_init(|| { | ||
| // vips_version(0) is the major number and vips_version(1) the minor. | ||
| let (major, minor) = unsafe { (bindings::vips_version(0), bindings::vips_version(1)) }; | ||
| let supported = major > 8 || (major == 8 && minor >= 16); | ||
| if !supported { | ||
| debug!("libvips {major}.{minor} has no gainmap keep flag; preserve_hdr will not retain one"); | ||
| } | ||
| supported | ||
| }) | ||
| } | ||
|
|
||
| /// Builds a libvips save suffix: `.png[option,option=value]`. | ||
| struct Suffix { | ||
| parts: Vec<String>, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When upgrading an installation that uses the recoverable disk or hybrid cache, a request containing
format_qualitythat was previously encoded underIMGFORGE_QUALITYkeeps the sameprocessed_cache_key, soprocess_pathreturns the old bytes before this new precedence is evaluated. Such URLs therefore continue receiving the incorrectly configured quality until eviction or manual cache deletion; include a cache namespace/version that distinguishes outputs produced with the corrected precedence.Useful? React with 👍 / 👎.