1 unstable release
new 0.1.0 | Mar 25, 2025 |
---|
#254 in Images
73 downloads per month
69KB
1K
SLoC
TrustMark — Rust
An implementation of TrustMark watermarking for the Content Authenticity Initiative (CAI) in Rust, as described in:
TrustMark - Universal Watermarking for Arbitrary Resolution Images
https://arxiv.org/abs/2311.18297
Tu Bui1, Shruti Agarwal2, John Collomosse1,2
1DECaDE Centre for the Decentralized Digital Economy, University of Surrey, UK.
2Adobe Research, San Jose CA.
This is a re-implementation of the trustmark Python library.
Quick start
cargo add trustmark
Download models
From the workspace root, run:
$ cargo xtask fetch-models
Run the CLI
From the workspace root, run:
$ cargo run --release -p trustmark-cli -- -m ./models encode -i ./images/bfly_rgba.png -o ./images/encoded.png
$ cargo run --release -p trustmark-cli -- -m ./models decode -i ./images/encoded.png
Use the library
use trustmark::{Trustmark, Version, Variant};
let tm = Trustmark::new("./models", Variant::Q, Version::Bch5).unwrap();
let input = image::open("../images/ghost.png").unwrap();
let output = tm.encode("0010101".to_owned(), input, 0.95);
Running the benchmarks
Rust benchmarks
To run the Rust benchmarks, run:
cargo bench
Python benchmarks
To run the Python benchmarks, run the following from the workspace root:
benches/load.sh && benches/encode.sh
Differences from the Python version
This crate implements a subset of the functionality of the Python version. Open an issue if there's something in the Python version that would be useful in this crate!
Dependencies
~8.5MB
~131K SLoC