Skip to content

Commit

Permalink
(MINOR) Removes xmp_write feature and xmp_toolkit (#461)
Browse files Browse the repository at this point in the history
xmp read/write now supported natively
  • Loading branch information
gpeacock authored May 1, 2024
1 parent ca3df05 commit e28dc87
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
1 change: 0 additions & 1 deletion make_test_images/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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"] }
Expand Down
25 changes: 14 additions & 11 deletions sdk/src/asset_handlers/jpeg_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 0 additions & 2 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions sdk/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit e28dc87

Please sign in to comment.