Skip to main content

TrustMark

This repository contains the official, open source implementation of TrustMark watermarking for the Content Authenticity Initiative (CAI) as described in:

TrustMark - Universal Watermarking for Arbitrary Resolution Images (arXiv:2311.18297) by Tu Bui1, Shruti Agarwal2, and John Collomosse1 2.

and later published at ICCV 2025 as TrustMark: Robust Watermarking and Watermark Removal for Arbitrary Resolution Images.

Overview

This repository contains the following directories:

  • /python: Python implementation of TrustMark for encoding, decoding and removing image watermarks (using PyTorch). For information on configuring TrustMark in Python, see Configuring TrustMark.
  • /js: Javascript implementation of TrustMark decoding of image watermarks (using ONNX). For more information, see TrustMark - JavaScript implementation.
  • /rust: Rust implementation of TrustMark. for more information, see TrustMark — Rust implementation.
  • /c2pa: Python example of how to indicate the presence of a TrustMark watermark in a C2PA manifest. For more information, see Using TrustMark with C2PA.

Model files (ckpt PyTorch file for Python and onnx ONNX file for JavaScript) are not packaged in this repository due to their size, but are downloaded upon first use. See the code for URLs and md5 hashes for a direct download link. Note that the location path was updated from Netlify to S3 in April 2026.

More information:

  • For answers to common questions, see the FAQ.
  • For information on configuring TrustMark in Python, see Configuring TrustMark.

Changelog

For a history of notable changes to the Python implementation, see the CHANGELOG.

Installation

Prerequisite

You must have Python 3.8.5 or higher to use the TrustMark Python implementation.

Installing from PyPI

The easiest way to install TrustMark is from the Python Package Index (PyPI) by entering this command:

pip install trustmark

Alternatively, after you've cloned the repository, you can install from the python directory:

cd trustmark/python
pip install .

Quickstart

To get started quickly, run the python/test-decode.py script that provides examples of watermarking several image files from the images directory.

Run the example

Run the example as follows:

cd trustmark/python
python test-decode.py

You'll see output like this:

Initializing TrustMark watermarking with ECC using [cpu]
Extracted secret: 1000000100001110000010010001011110010001011000100000100110110 (schema 1)
PSNR = 50.357909
No secret after removal

Example script

The python/test-decode.py script provides examples of watermarking a JPEG photo, a JPEG GenAI image, and an RGBA PNG image. The example uses TrustMark variant Q to encode the word mysecret in ASCII7 encoding into the image ufo_240.jpg which is then decoded, and then removed from the image.

from trustmark import TrustMark
from PIL import Image

# init
tm=TrustMark(verbose=True, model_type='Q') # or try P

# encoding example
cover = Image.open('images/ufo_240.jpg').convert('RGB')
tm.encode(cover, 'mysecret').save('ufo_240_Q.png')

# decoding example
cover = Image.open('images/ufo_240_Q.png').convert('RGB')
wm_secret, wm_present, wm_schema = tm.decode(cover)

if wm_present:
   print(f'Extracted secret: {wm_secret}')
else:
   print('No watermark decoded')

# removal example
stego = Image.open('images/ufo_240_Q.png').convert('RGB')
im_recover = tm.remove_watermark(stego)
im_recover.save('images/recovered.png')

Data schema

TrustMark encodes a payload (the watermark data embedded within the image) of 100 bits. You can configure an error correction level over the raw 100 bits of payload to maintain reliability under transformations or noise.

In payload encoding, the version bits comprise two reserved (unused) bits, and two bits encoding an integer value 0-3 that specifies the data schema as follows:

  • 0: BCH_SUPER
  • 1: BCH_5
  • 2: BCH_4
  • 3: BCH_3

For more details and information on configuring the encoding mode in Python, see Configuring TrustMark.

Citation

If you find this work useful, please give us a star ⭐ and cite the repository and/or TrustMark paper, preferrably as follows:

@inproceedings{Trustmark-ICCV-2025,
  title = {TrustMark: Robust Watermarking and Watermark Removal for Arbitrary Resolution Images},
  author={Bui, Tu and Agarwal, Shruti and Collomosse, John},
  booktitle = {IEEE International Conference on Computer Vision (ICCV)},
  year = {2025},
  month = oct
}

or cite the earlier ArXiv version:

@article{Trustmark-ArXiv-2023,
title={Trustmark: Universal Watermarking for Arbitrary Resolution Images},
author={Bui, Tu and Agarwal, Shruti and Collomosse, John},
journal = {ArXiv e-prints},
archivePrefix = "arXiv",
eprint = {2311.18297},
year = 2023,
month = nov
}

License

This package is is distributed under the terms of the MIT license. The MIT license covers both the code in this repo and the model files which are downloaded upon first use.

  1. DECaDE Centre for the Decentralized Digital Economy, University of Surrey, UK. ↩ ↩2

  2. Adobe Research, San Jose, CA. ↩ ↩2

Metadata

Release files for trustmark 0.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trustmark 0.9.2
File Size Uploaded
trustmark-0.9.2.tar.gz 63.8 kB Details

Release files / trustmark-0.9.2.tar.gz

Download URL trustmark-0.9.2.tar.gz
Size 63.8 kB
Tags Source
SHA-256 checksum
How to use checksums
bcaa3bc38ead1c0558df81932672f34e306efaed31389da57dbed100e236b28a
BLAKE2b-256 checksum
How to use checksums
534132e84596af94e8696c55060d55eb9eed9d99722a673d12212a1c0c4ef1d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

0.9.2 This release

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.0

1 release file

0.7.0

1 release file

0.6.3

1 release file

0.6.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page