commit e28dc875947251c956ca7dcfeaf5d571806a1e82
parent ca3df05381f5bccb864502d09274432aa37e6018
Author: Gavin Peacock <gpeacock@adobe.com>
Date: Wed, 1 May 2024 11:40:41 -0700
(MINOR) Removes xmp_write feature and xmp_toolkit (#461)
xmp read/write now supported natively
Diffstat:
5 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/make_test_images/Cargo.toml b/make_test_images/Cargo.toml
@@ -10,7 +10,6 @@ rust-version = "1.73.0"
anyhow = "1.0.40"
c2pa = { path = "../sdk", default-features = false, features = [
"openssl",
- "xmp_write",
"unstable_api",
] }
env_logger = "0.10"
diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml
@@ -30,7 +30,6 @@ add_thumbnails = ["image"]
psxxx_ocsp_stapling_experimental = []
file_io = ["openssl_sign"]
serialize_thumbnails = []
-xmp_write = ["xmp_toolkit"]
no_interleaved_io = ["file_io"]
fetch_remote_manifests = []
openssl_sign = ["openssl"]
@@ -137,7 +136,6 @@ image = { version = "0.24.7", default-features = false, features = [
], optional = true }
instant = "0.1.12"
openssl = { version = "0.10.61", features = ["vendored"], optional = true }
-xmp_toolkit = { version = "1.7.1", optional = true }
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_log = { version = "1.0.0", features = ["color"] }
diff --git a/sdk/src/asset_handlers/jpeg_io.rs b/sdk/src/asset_handlers/jpeg_io.rs
@@ -555,17 +555,20 @@ impl RemoteRefEmbed for JpegIO {
asset_path: &Path,
embed_ref: crate::asset_io::RemoteRefEmbedType,
) -> Result<()> {
- match embed_ref {
- crate::asset_io::RemoteRefEmbedType::Xmp(manifest_uri) => {
- #[cfg(feature = "xmp_write")]
- {
- crate::embedded_xmp::add_manifest_uri_to_file(asset_path, &manifest_uri)
- }
-
- #[cfg(not(feature = "xmp_write"))]
- {
- Err(crate::error::Error::MissingFeature("xmp_write".to_string()))
- }
+ match &embed_ref {
+ crate::asset_io::RemoteRefEmbedType::Xmp(_manifest_uri) => {
+ let mut file = std::fs::File::open(asset_path)?;
+ let mut temp = Cursor::new(Vec::new());
+ self.embed_reference_to_stream(&mut file, &mut temp, embed_ref)?;
+ let mut output = std::fs::OpenOptions::new()
+ .read(true)
+ .write(true)
+ .truncate(true)
+ .open(asset_path)
+ .map_err(Error::IoError)?;
+ temp.set_position(0);
+ std::io::copy(&mut temp, &mut output).map_err(Error::IoError)?;
+ Ok(())
}
crate::asset_io::RemoteRefEmbedType::StegoS(_) => Err(Error::UnsupportedType),
crate::asset_io::RemoteRefEmbedType::StegoB(_) => Err(Error::UnsupportedType),
diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs
@@ -146,8 +146,6 @@ pub(crate) mod callback_signer;
pub(crate) mod claim;
pub(crate) mod claim_generator_info;
pub(crate) mod cose_validator;
-#[cfg(all(feature = "xmp_write", feature = "file_io"))]
-pub(crate) mod embedded_xmp;
pub(crate) mod error;
pub(crate) mod hashed_uri;
pub(crate) mod ingredient;
diff --git a/sdk/src/manifest.rs b/sdk/src/manifest.rs
@@ -1717,7 +1717,7 @@ pub(crate) mod tests {
);
}
- #[cfg(all(feature = "file_io", feature = "xmp_write"))]
+ #[cfg(feature = "file_io")]
#[test]
fn test_embed_user_label() {
let temp_dir = tempdir().expect("temp dir");
@@ -1738,7 +1738,7 @@ pub(crate) mod tests {
);
}
- #[cfg(all(feature = "file_io", feature = "xmp_write"))]
+ #[cfg(feature = "file_io")]
#[test]
fn test_embed_sidecar_user_label() {
let temp_dir = tempdir().expect("temp dir");
@@ -1947,7 +1947,7 @@ pub(crate) mod tests {
assert!(manifest_store.validation_status().is_none())
}
- #[cfg(all(feature = "file_io", feature = "xmp_write"))]
+ #[cfg(feature = "file_io")]
#[test]
fn test_embed_sidecar_with_parent_manifest() {
let temp_dir = tempdir().expect("temp dir");