From e4efca36aa0134b9fa0fd5a08e0fb36fbd015b1f Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 11 Nov 2026 16:24:44 -0500 Subject: [PATCH] fix(engine): apply the metadata choice to WebP Quick Export (#11058) --- crates/engine/src/cmd/web_cmds/quick.rs | 7 ++++++- crates/engine/src/cmd/web_cmds/tests.rs | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/web_cmds/quick.rs b/crates/engine/src/cmd/web_cmds/quick.rs index 916a06f8d2..afe499ffdb 100644 --- a/crates/engine/src/cmd/web_cmds/quick.rs +++ b/crates/engine/src/cmd/web_cmds/quick.rs @@ -114,7 +114,12 @@ pub(super) fn quick_export(s: &mut Session, p: &Value) -> Result { // WebP uses the regular exporter. Its optional quality is in the Photoshop-style // 0–12 save scale: invert that mapping so the codec receives the chosen 1–100. // Keeping quality absent preserves the historical lossless Quick Export behavior. - let (wdoc, _, _) = web_document(&doc, &json!({}), &WebSettings { convert_to_srgb: prefs.convert_to_srgb, ..Default::default() })?; + let st = WebSettings::from_params(&Value::Object(o.clone()), cmd)?; + let (mut wdoc, _, _) = web_document(&doc, &json!({}), &st)?; + // The regular exporter embeds the document's XMP and EXIF as they are: give it only + // what the metadata choice keeps, as the Save for Web formats get. + wdoc.metadata.xmp = web_xmp(&doc, st.metadata).map(std::sync::Arc::from); + wdoc.metadata.exif = web_exif(&doc, st.metadata).map(|e| std::sync::Arc::new(e.to_vec())); let quality = if prefs.webp_lossless { None } else { Some((f64::from(prefs.webp_quality.clamp(1, 100)) - 1.0) * 12.0 / 99.0) }; let warnings = crate::file_cmds::save_doc(&wdoc, &path, quality)?; crate::automate_cmds::fire_event(s, "export"); diff --git a/crates/engine/src/cmd/web_cmds/tests.rs b/crates/engine/src/cmd/web_cmds/tests.rs index 82c2a6c5a9..ef7e3c3ea6 100644 --- a/crates/engine/src/cmd/web_cmds/tests.rs +++ b/crates/engine/src/cmd/web_cmds/tests.rs @@ -1396,6 +1396,25 @@ fn embed_color_profile_tags_an_untagged_document_srgb() { } } +/// Quick Export as WebP goes through the regular exporter, which embeds a document's XMP and +/// EXIF whole: the export preferences' metadata choice must still apply to it. +#[test] +fn quick_export_webp_keeps_only_the_chosen_metadata() { + let dir = tmp("quick_webp_metadata"); + let mut s = session(8); + s.execute("file.fileInfo", json!({"copyright": "© Example", "description": "secret notes"})).unwrap(); + let has = |b: &[u8], needle: &[u8]| b.windows(needle.len()).any(|w| w == needle); + for (choice, lossless) in [("none", true), ("copyright", false)] { + s.execute("file.export.exportPreferences", json!({"quickExportFormat": "png", "metadata": choice, "webpLossless": lossless})).unwrap(); + let path = format!("{dir}/{choice}.webp"); + s.execute("file.export.quickExport", json!({"path": path})).unwrap(); + let bytes = std::fs::read(&path).unwrap(); + assert!(!has(&bytes, b"secret notes"), "{choice}: the description is not {choice}"); + assert_eq!(has(&bytes, b"Example"), choice == "copyright", "{choice}"); + } + s.execute("prefs.reset", json!({"path": "export"})).unwrap(); +} + /// #5305: `folder` writes the whole image there under the document's own name, so an action /// recorded with the suggested name saves each document it is played on under that name; it is /// a destination, never a remembered setting.