mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-17 23:46:10 +00:00
doc_export_layers takes maximizeCompatibility for PSD/PSB layer files (#8064)
ExportLayersParams refuses unknown fields, so an MCP caller could not pass the option Layers to Files already honours. It is now accepted and forwarded; unset, the preference decides as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a1bb9f003f
commit
294ffa28d9
2 files changed
+29
No files matched your search
@@ -113,6 +113,10 @@ pub struct ExportLayersParams {
|
||||
/// Encoder quality, 0..12, for the formats that take one.
|
||||
#[serde(default)]
|
||||
pub quality: Option<f64>,
|
||||
/// PSD/PSB: write the real merged image (Photoshop's Maximize Compatibility); false writes
|
||||
/// Photoshop's white placeholder. Unset: the engine's Preferences › File Handling decides.
|
||||
#[serde(default, rename = "maximizeCompatibility")]
|
||||
pub maximize_compatibility: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, JsonSchema)]
|
||||
@@ -804,6 +808,9 @@ impl PhotocraftMcp {
|
||||
if let Some(v) = p.quality {
|
||||
opts.insert("quality".into(), json!(v));
|
||||
}
|
||||
if let Some(v) = p.maximize_compatibility {
|
||||
opts.insert("maximizeCompatibility".into(), json!(v));
|
||||
}
|
||||
let opts = Value::Object(opts);
|
||||
// Bridge mode runs the app on this machine, which writes its own paths like any command.
|
||||
let mut bridge_params = opts.clone();
|
||||
|
||||
@@ -541,6 +541,28 @@ async fn headless_doc_save_takes_maximize_compatibility() {
|
||||
cleanup(&dir);
|
||||
}
|
||||
|
||||
/// #8064: `doc_export_layers` takes `maximizeCompatibility` too, for PSD/PSB layer files.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn headless_doc_export_layers_takes_maximize_compatibility() {
|
||||
let dir = tmp("export-layers-maximize-compat");
|
||||
let client = connect(headless_in(&dir)).await;
|
||||
call(&client, "doc_new", json!({"width": 16, "height": 16, "background": "white", "name": "card"})).await;
|
||||
for (sub, params, real) in
|
||||
[("on", json!({"dir": "on", "format": "psd"}), true), ("off", json!({"dir": "off", "format": "psd", "maximizeCompatibility": false}), false)]
|
||||
{
|
||||
let result = json_of(&call(&client, "doc_export_layers", params.clone()).await);
|
||||
assert_eq!(result["count"], 1, "{params}: {result}");
|
||||
let file = result["files"][0].as_str().unwrap();
|
||||
assert!(file.starts_with(sub), "{file}");
|
||||
let bytes = std::fs::read(dir.join(file)).unwrap();
|
||||
assert_eq!(photocraft_psd::PsdFile::from_bytes(&bytes).unwrap().has_real_merged_data(), Some(real), "{params}");
|
||||
}
|
||||
let r = call(&client, "doc_export_layers", json!({"dir": "bad", "format": "psd", "maximizeCompatibility": "no"})).await;
|
||||
assert_eq!(r.is_error, Some(true), "{}", text(&r));
|
||||
client.cancel().await.unwrap();
|
||||
cleanup(&dir);
|
||||
}
|
||||
|
||||
/// #8064: `maximizeCompatibility` reaches the app's `app.save` through the bridge; unset, nothing
|
||||
/// is sent and the app's preference decides.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
|
||||
Reference in new issue
Block a user