Go CodeQL Build Farcaster Page

C2PA Metadata Remover

A lightweight tool for detecting and removing Content Authenticity Initiative (C2PA) metadata from image files. Available as both a CLI tool and a WebAssembly module.

What is C2PA?

C2PA (Coalition for Content Provenance and Authenticity) is a metadata standard used to track the origin and edit history of media content. While it serves legitimate purposes in combating misinformation and deepfakes, it also raises privacy concerns as it can contain identifiable information about the device that created an image and its user.

Features

Installation

CLI Tool

From Source

# Requires Go 1.24.2 or later
git clone https://github.com/ngmisl/C2PAremover.git
cd C2PAremover
go build -o c2paremover .

Using Make

The project includes a Makefile to simplify building:

# Build native binary
make build

# Build WebAssembly binary
make wasm

# Build both
make all

# Install to system (requires sudo for /usr/local/bin)
sudo make install

WebAssembly Module

# Install using Wasmer
wasmer install metaend/c2paremover

# Or run directly from Wasmer.io registry
wasmer run metaend/c2paremover@0.1.5

Usage

CLI Tool

# Check and remove C2PA metadata from a single file
c2paremover input.jpg output.jpg

# Process multiple files
c2paremover input1.jpg output1.jpg input2.png output2.png

# Check directory (creates cleaned copies with "_clean" suffix)
c2paremover -d /path/to/directory

# Check if an image has C2PA metadata without removing it
c2paremover check input.jpg

WebAssembly Module

The WASM module reads from stdin and writes to stdout:

# Process a single file
cat input.jpg | wasmer run c2paremover > cleaned.jpg

# Process Adobe test file with C2PA metadata
cat adobe-20220124-CAICA.jpg | wasmer run metaend/c2paremover > cleaned.jpg

# Process and chain with other tools
cat input.jpg | wasmer run c2paremover | convert - -resize 800x600 output.jpg

Why Wasmer?

The WebAssembly version offers several advantages:

Build Options

Standard CLI Build

go build .

WebAssembly Build

GOOS=wasip1 GOARCH=wasm go build -o c2paremover.wasm -tags=wasmer .

Using Make

# Build all targets
make all

How It Works

The tool performs the following operations:

  1. Detects the image format (JPEG or PNG)
  2. Parses the file structure to identify C2PA metadata
    - For JPEG: Checks for APP11 (0xEB) segments and APP1 (XMP) containing C2PA namespaces
    - For PNG: Checks for text chunks (iTXt and tEXt) containing C2PA references
  3. When removing metadata:
    - Primarily attempts a “smart mode” by re-encoding the decoded image
    - If smart mode fails or doesn’t fully remove C2PA:

Recent Improvements

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

View on GitHub