commit 75bc275b14d5662306859fe14d2ba29b5a141c80
parent 1804adb63945639f509ef0bccf9c5bd528395191
Author: Dave Kozma <dkozma@adobe.com>
Date: Thu, 13 Jul 2023 13:51:01 -0400
(MINOR) Minor improvements for Wasm and Node.js interoperability (#276)
* Minor improvements for Wasm and Node.js interoperability
* Add `add_thumbnails` flag to `make_test_images`
* Revert image version to 0.24.2
* update readme, cleanup clippy errors
---------
Co-authored-by: Gavin Peacock <gpeacock@adobe.com>
Diffstat:
8 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
@@ -93,6 +93,14 @@ Note that some components and dependent crates are licensed under different term
This section gives a highlight of noteworthy changes
Refer to the [CHANGELOG](https://github.com/contentauth/c2pa-rs/blob/main/CHANGELOG.md) for detailed Git changes
+
+## 0.25.0
+_14 July 2023_
+* (important!) the add_thumbnails feature is no longer tied to file_io, so you will need to specify it or thumbnails will not be generated.
+* DataHash and BoxHash SDK support (generates a signed manifest ready to write into a file without writing to the file)
+* Expose CAIRead and CAIWrite traits required by some SDK calls.
+* Bug fix for certain BMFF formats (AVIF) that causes images to be unreadable
+
## 0.24.0
_21 June 2023_
* Bump minor version to 0.24.0 to signify change in signature (back to the compatible one)
diff --git a/make_test_images/Cargo.toml b/make_test_images/Cargo.toml
@@ -9,7 +9,11 @@ rust-version = "1.65.0"
[dependencies]
anyhow = "1.0.40"
blake3 = "1.0.0"
-c2pa = { path="../sdk", features = ["file_io", "xmp_write"] }
+c2pa = { path = "../sdk", features = [
+ "add_thumbnails",
+ "file_io",
+ "xmp_write",
+] }
env_logger = "0.10"
log = "0.4.8"
half = "<2.3.0, < 3" # fix for older versions of rust
diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml
@@ -27,7 +27,7 @@ rustdoc-args = ["--cfg", "docsrs"]
[features]
default = []
add_thumbnails = ["image"]
-file_io = ["add_thumbnails", "openssl_sign"]
+file_io = ["openssl_sign"]
serialize_thumbnails = []
xmp_write = ["xmp_toolkit"]
no_interleaved_io = ["file_io"]
@@ -110,7 +110,7 @@ openssl = { version = "0.10.48", features = ["vendored"], optional = true }
xmp_toolkit = { version = "1.0", optional = true }
[target.'cfg(target_arch = "wasm32")'.dependencies]
-console_log = { version = "0.2", features = ["color"] }
+console_log = { version = "1.0.0", features = ["color"] }
getrandom = { version = "0.2.7", features = ["js"] }
# We need to use the `inaccurate` flag here to ensure usage of the JavaScript Date API
# to handle certificate timestamp checking correctly.
diff --git a/sdk/src/asset_io.rs b/sdk/src/asset_io.rs
@@ -39,7 +39,11 @@ pub struct HashObjectPositions {
pub length: usize, // length of object
pub htype: HashBlockObjectType, // type of hash block object
}
-/// CAIReader trait to insure CAILoader method support both Read & Seek
+
+// Disable `Send` for wasm32 since we are not sending data across threads
+#[cfg(target_arch = "wasm32")]
+pub trait CAIRead: Read + Seek {}
+#[cfg(not(target_arch = "wasm32"))]
pub trait CAIRead: Read + Seek + Send {}
impl CAIRead for std::fs::File {}
@@ -108,6 +112,7 @@ impl Seek for CAIReadWriteWrapper<'_> {
}
}
+/// CAIReader trait to insure CAILoader method support both Read & Seek
// Interface for in memory CAI reading
pub trait CAIReader: Sync + Send {
// Return entire CAI block as Vec<u8>
diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs
@@ -123,6 +123,7 @@ pub(crate) mod asn1;
pub(crate) mod assertion;
pub(crate) mod asset_handlers;
pub(crate) mod asset_io;
+pub use asset_io::{CAIRead, CAIReadWrite};
/// crate private declarations
pub(crate) mod claim;
diff --git a/sdk/src/store.rs b/sdk/src/store.rs
@@ -4150,7 +4150,7 @@ pub mod tests {
}
#[test]
- #[cfg(all(feature = "file_io"))]
+ #[cfg(feature = "file_io")]
fn test_removed_jumbf() {
// test adding to actual image
let ap = fixture_path("no_manifest.jpg");
diff --git a/sdk/src/utils/mod.rs b/sdk/src/utils/mod.rs
@@ -18,7 +18,7 @@ pub(crate) mod hash_utils;
pub(crate) mod merkle;
#[allow(dead_code)] // for wasm build
pub(crate) mod patch;
-#[cfg(all(feature = "add_thumbnails", any(feature = "file_io")))]
+#[cfg(feature = "add_thumbnails")]
pub(crate) mod thumbnail;
pub(crate) mod time_it;
#[allow(dead_code)] // for wasm builds
diff --git a/sdk/src/utils/thumbnail.rs b/sdk/src/utils/thumbnail.rs
@@ -23,6 +23,7 @@ const THUMBNAIL_JPEG_QUALITY: u8 = 80;
/// utility to generate a thumbnail from a file at path
/// returns Result (format, image_bits) if successful, otherwise Error
+#[cfg(feature = "file_io")]
pub fn make_thumbnail(path: &std::path::Path) -> Result<(String, Vec<u8>)> {
let format = ImageFormat::from_path(path)?;