How adobe/trustmark works
Project type and purpose
• TrustMark is an open-source, multi-language toolkit for embedding, decoding, and removing robust watermarks in images, based on the “TrustMark” universal watermarking paper.
• It provides three parallel implementations: a Python library (PyTorch-based), a JavaScript decoder (ONNX + WebAssembly), and a Rust library + CLI. It also includes a Python example for C2PA manifest integration.
File structure
Top-level layout:
• c2pa/ – Python example showing how to inject a watermark presence into a C2PA manifest.
• images/ – Sample images used by the Python test script.
• js/ – Browser/Node decoder using ONNX, with WASM dependencies.
• python/ – Core Python package: modules under trustmark/, configuration, tests, packaging.
• rust/ – Cargo workspace with two crates (trustmark-cli and xtask), plus pure-Rust library code under src/.
Key patterns:
• Multi-module, language-specific wrappers around a shared algorithm.
• Pretrained model downloads at runtime – configured in Python trustmark.py.
• CLI vs. library dichotomy in Rust (trustmark-cli crate vs. core lib).
• JS uses a static ONNX runtime build in wasm and a thin data-layer / watermark logic wrapper.
README for architectural clues
• Python: uses PyTorch to train/infer UNet-based watermark encoder/decoder + BCH/ECC error-correction.
• JS: uses ONNX models compiled to WASM modules + lightweight JS glue.
• Rust: performant native routines for image processing, ECC (bch.rs), embedding logic, plus a CLI frontend.
• C2PA example ties into the CAI manifest JSON.
Detail
• Files or modules next to components (e.g., python/trustmark/trustmark.py, js/tm_watermark.js, rust/src/bits/bch.rs).
• Do not over-abstract: list each implementation pipeline separately, even if they share logic.