Skip to content
← All tutorials

Tutorial · Images

Mark an AI image in four lines of Python, then try to strip the label

Watermark and C2PA-sign an AI-generated image with the Python SDK, then screenshot, crop, compress and shrink it. Every copy loses its Content Credentials; the watermark survives all four.

0:37 video · Real run on 20 November 2026 · Markproof

0:37 · text on screen, no narration

In short

  • An AI-generated image that shipped with no label at all gets an invisible watermark and signed Content Credentials (C2PA) from one SDK call.
  • Then it's screenshotted, cropped, compressed and shrunk, the way images get treated online every day.
  • Every copy loses its Content Credentials. The watermark survives all four, with the same code. That's why Article 50 marking needs both layers.

1. Install the SDK

You need Python 3 and a Markproof API key: sign up and copy it from your dashboard (250 free calls a month). Keep the key on your server, in an environment variable.

Terminal
pip install markproof pillow

2. Mark the image

The image is a photorealistic lighthouse from an AI image model that adds no machine-readable label of its own. One call adds both layers and returns the marked file and a public verify link:

mark.py
import osfrom markproof import Markproof client = Markproof(api_key=os.environ["MARKPROOF_API_KEY"]) marked = client.mark("lighthouse.jpg")open("lighthouse.marked.png", "wb").write(marked.file)print(marked.verify_url)
Output
https://markproof.co/v/WN3YZ16R

The marked file looks the same as the original. Measured, the average change is 0.76 out of 255 per pixel (47.3 dB PSNR), which you can't see. You can open the verify page for WN3YZ16R to see the public record.

3. Try to break it

Next come four everyday edits: a real screen capture of the image in a browser, then a crop, heavy JPEG compression and a shrink. Each copy goes back through the API:

attack.py
from PIL import Image img = Image.open("lighthouse.marked.png").convert("RGB")w, h = img.sizeimg.crop((int(w * 0.1), 0, int(w * 0.9), h)).save("crop-4x5.png")  # cut for Instagramimg.save("jpeg-q50.jpg", quality=50)                              # heavy compressionimg.resize((int(w * 0.4), int(h * 0.4))).save("small-40.png")      # thumbnail size for name in ["screenshot.png", "crop-4x5.png", "jpeg-q50.jpg", "small-40.png"]:    print(name, client.verify(name).summary)
CopySizeContent CredentialsWatermark
Marked original1024×1024Present and validFound, WN3YZ16R, matches the record
Screenshot (cropped to the image)735×735GoneFound, WN3YZ16R, matches the record
Cropped to 4:5819×1024GoneFound, WN3YZ16R, matches the record
JPEG, quality 501024×1024GoneFound, WN3YZ16R, matches the record
Shrunk to 40%409×409GoneFound, WN3YZ16R, matches the record

You get the same result from the free checker: drop any of the copies in and it reports the watermark found and the Content Credentials missing.

Why it matters

Article 50(2) of the EU AI Act asks providers of generative AI to mark output in a machine-readable way that's detectable as AI-generated. C2PA Content Credentials carry the detail (what made the file, and when) but live in metadata, which a screenshot or a re-upload removes. The watermark lives in the pixels, so it's still there after the edits that strip the metadata. Using both means an untouched file carries the full signed record, and an edited copy can still be traced.

Using the Vercel AI SDK, Node.js or plain HTTP instead? The same marking takes one wrapper or one request: see Add Article 50 marking to your AI app in 10 minutes. This is technical guidance, not legal advice.

Check your own output in seconds.

Drop a file into the free checker to see whether it carries a watermark and Content Credentials. Then mark your files with one API call: 250 free calls a month, no card required.