# How Instagram Detects AI Images: C2PA, IPTC and XMP Explained (With Code to Inspect Them)

> Source: <https://dev.to/aiflagremover/how-instagram-detects-ai-images-c2pa-iptc-and-xmp-explained-with-code-to-inspect-them-28ia>
> Published: 2026-11-20 23:02:15+00:00

**Recommendation:** Inspect images with ExifTool's -DigitalSourceType and -JUMBF:all flags before trusting or clearing an AI label, and rebuild files by skipping metadata chunks rather than re-encoding.
More in the playbook "Verifying model output": <https://wpnews.pro/playbooks/output-verification>

If you've ever seen Instagram put an **"AI info"** label on a photo you know is real, the cause is almost never the pixels. It's metadata. I've spent the last few months building [AI Flag Remover](https://aiflagremover.com), a browser-based tool that strips this metadata, so here's what I learned about where it lives and how to inspect it yourself.

| Signal | Where it lives | Who writes it | Who reads it | 
|---|---|---|---|
| **C2PA manifest** | JUMBF boxes (JPEG APP11, PNG `caBX` chunk, WebP`C2PA` chunk) | Adobe, OpenAI, Google, Microsoft | TikTok, LinkedIn, Meta, Pinterest | 
| **IPTC Digital Source Type** | XMP packet, `Iptc4xmpExt:DigitalSourceType` | Meta AI, many generators | Meta (Instagram, Facebook, Threads) | 
| **Generator text** | PNG `tEXt` /`iTXt` chunks (`parameters` ,`prompt` ,`workflow` ) | Stable Diffusion WebUI, ComfyUI, Forge | Anyone who opens the file | 

The IPTC value to look for is a URI ending in `trainedAlgorithmicMedia` (fully generated) or `compositeWithTrainedAlgorithmicMedia` (real photo edited with AI). That second one is the usual culprit when a real photo gets labelled after a Generative Fill edit.

The quickest check, if you have [ExifTool](https://exiftool.org/) installed:

```
# Show the IPTC digital source type and any C2PA/JUMBF data
exiftool -G1 -a -s -DigitalSourceType -JUMBF:all -XMP-iptcExt:all photo.jpg

# For Stable Diffusion PNGs, show the embedded prompt
exiftool -PNG:Parameters -PNG:Prompt -PNG:Workflow image.png
```

C2PA in JPEGs sits in APP11 segments containing a JUMBF box labelled `c2pa`. This scans the segment markers:

``` python
import sys

def find_c2pa_jpeg(path):
    data = open(path, "rb").read()
    i = 2  # skip SOI
    found = []
    while i < len(data) - 4 and data[i] == 0xFF:
        marker = data[i + 1]
        length = int.from_bytes(data[i + 2:i + 4], "big")
        segment = data[i + 4:i + 2 + length]
        if marker == 0xEB and b"c2pa" in segment:      # APP11 + JUMBF label
            found.append(("APP11/C2PA", length))
        if marker == 0xE1 and b"DigitalSourceType" in segment:  # APP1 XMP
            found.append(("XMP/DigitalSourceType", length))
        if marker == 0xDA:  # start of scan, image data follows
            break
        i += 2 + length
    return found

print(find_c2pa_jpeg(sys.argv[1]) or "No AI metadata markers found")
```

Stable Diffusion prompts are plain `tEXt` chunks, so a few lines of JavaScript can read them client-side:

``` js
async function readPngText(file) {
  const buf = new DataView(await file.arrayBuffer());
  const out = {};
  let p = 8; // skip PNG signature
  while (p < buf.byteLength) {
    const len = buf.getUint32(p);
    const type = String.fromCharCode(...new Uint8Array(buf.buffer, p + 4, 4));
    if (type === "tEXt") {
      const bytes = new Uint8Array(buf.buffer, p + 8, len);
      const [key, ...val] = new TextDecoder("latin1").decode(bytes).split("\0");
      out[key] = val.join("\0");
    }
    if (type === "caBX") out.c2pa = `${len} bytes`;
    p += 12 + len; // length + type + data + CRC
  }
  return out; // e.g. { parameters: "a cat, 8k ... Steps: 30, Seed: 1234" }
}
```

Removing a chunk is just skipping it when you rebuild the file. Because you're copying the image data chunks byte for byte, there's **no re-encoding and no quality loss**.

`IFD1` too if privacy matters.
C2PA exists for good reasons: provenance helps people spot fakes. Stripping it makes sense for **false positives** (real photos with a minor AI edit) and **privacy** (GPS, serial numbers, leaked prompts). If content is genuinely AI-generated, platforms and laws like the EU AI Act may still require you to disclose it.

If you just need clean files, [AI Flag Remover](https://aiflagremover.com) does all of the above in the browser (JPG, PNG, WebP, HEIC, AVIF), shows which AI flags it found, and re-checks the output. There's also a free [AI image metadata checker](https://aiflagremover.com/ai-image-checker) if you only want to inspect.

What other metadata quirks have you run into? Let me know in the comments.
