{"slug": "how-instagram-detects-ai-images-c2pa-iptc-and-xmp-explained-with-code-to-inspect", "title": "How Instagram Detects AI Images: C2PA, IPTC and XMP Explained (With Code to Inspect Them)", "summary": "A developer built AI Flag Remover, a browser-based tool that strips AI-provenance metadata from images, and documented where Instagram's \"AI info\" labels actually come from: C2PA manifests in JUMBF boxes, the IPTC DigitalSourceType XMP field (trainedAlgorithmicMedia or compositeWithTrainedAlgorithmicMedia), and Stable Diffusion prompt text in PNG tEXt chunks. The writeup includes ExifTool commands plus Python and JavaScript snippets for locating C2PA APP11 segments and PNG text chunks, and notes that removing chunks during a byte-for-byte rebuild avoids re-encoding and quality loss. The developer frames stripping as useful for false positives and privacy, while cautioning that genuinely AI-generated content may still require disclosure under platform rules and the EU AI Act.", "body_md": "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.\n\n| Signal | Where it lives | Who writes it | Who reads it | \n|---|---|---|---|\n| **C2PA manifest** | JUMBF boxes (JPEG APP11, PNG `caBX` chunk, WebP`C2PA` chunk) | Adobe, OpenAI, Google, Microsoft | TikTok, LinkedIn, Meta, Pinterest | \n| **IPTC Digital Source Type** | XMP packet, `Iptc4xmpExt:DigitalSourceType` | Meta AI, many generators | Meta (Instagram, Facebook, Threads) | \n| **Generator text** | PNG `tEXt` /`iTXt` chunks (`parameters` ,`prompt` ,`workflow` ) | Stable Diffusion WebUI, ComfyUI, Forge | Anyone who opens the file | \n\nThe 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.\n\nThe quickest check, if you have [ExifTool](https://exiftool.org/) installed:\n\n```\n# Show the IPTC digital source type and any C2PA/JUMBF data\nexiftool -G1 -a -s -DigitalSourceType -JUMBF:all -XMP-iptcExt:all photo.jpg\n\n# For Stable Diffusion PNGs, show the embedded prompt\nexiftool -PNG:Parameters -PNG:Prompt -PNG:Workflow image.png\n```\n\nC2PA in JPEGs sits in APP11 segments containing a JUMBF box labelled `c2pa`. This scans the segment markers:\n\n``` python\nimport sys\n\ndef find_c2pa_jpeg(path):\n    data = open(path, \"rb\").read()\n    i = 2  # skip SOI\n    found = []\n    while i < len(data) - 4 and data[i] == 0xFF:\n        marker = data[i + 1]\n        length = int.from_bytes(data[i + 2:i + 4], \"big\")\n        segment = data[i + 4:i + 2 + length]\n        if marker == 0xEB and b\"c2pa\" in segment:      # APP11 + JUMBF label\n            found.append((\"APP11/C2PA\", length))\n        if marker == 0xE1 and b\"DigitalSourceType\" in segment:  # APP1 XMP\n            found.append((\"XMP/DigitalSourceType\", length))\n        if marker == 0xDA:  # start of scan, image data follows\n            break\n        i += 2 + length\n    return found\n\nprint(find_c2pa_jpeg(sys.argv[1]) or \"No AI metadata markers found\")\n```\n\nStable Diffusion prompts are plain `tEXt` chunks, so a few lines of JavaScript can read them client-side:\n\n``` js\nasync function readPngText(file) {\n  const buf = new DataView(await file.arrayBuffer());\n  const out = {};\n  let p = 8; // skip PNG signature\n  while (p < buf.byteLength) {\n    const len = buf.getUint32(p);\n    const type = String.fromCharCode(...new Uint8Array(buf.buffer, p + 4, 4));\n    if (type === \"tEXt\") {\n      const bytes = new Uint8Array(buf.buffer, p + 8, len);\n      const [key, ...val] = new TextDecoder(\"latin1\").decode(bytes).split(\"\\0\");\n      out[key] = val.join(\"\\0\");\n    }\n    if (type === \"caBX\") out.c2pa = `${len} bytes`;\n    p += 12 + len; // length + type + data + CRC\n  }\n  return out; // e.g. { parameters: \"a cat, 8k ... Steps: 30, Seed: 1234\" }\n}\n```\n\nRemoving 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**.\n\n`IFD1` too if privacy matters.\nC2PA 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.\n\nIf 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.\n\nWhat other metadata quirks have you run into? Let me know in the comments.", "url": "https://wpnews.pro/news/how-instagram-detects-ai-images-c2pa-iptc-and-xmp-explained-with-code-to-inspect", "canonical_source": "https://dev.to/aiflagremover/how-instagram-detects-ai-images-c2pa-iptc-and-xmp-explained-with-code-to-inspect-them-28ia", "published_at": "2026-11-20 23:02:15+00:00", "updated_at": "2026-11-20 23:14:43.472407+00:00", "lang": "en", "topics": ["artificial-intelligence", "generative-ai", "ai-ethics", "ai-policy", "developer-tools"], "entities": ["Instagram", "Meta", "AI Flag Remover", "C2PA", "IPTC", "Adobe", "OpenAI", "Stable Diffusion"], "also_reported_by": [], "takeaway": "AI labels on Instagram come from metadata, not pixels: check JPEG APP11 segments for a JUMBF 'c2pa' box and APP1 XMP for Iptc4xmpExt:DigitalSourceType, and strip chunks by skipping them during a byte-for-byte rebuild to avoid re-encoding.", "recommendation": {"advice": "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.", "playbook": "output-verification", "playbook_url": "https://wpnews.pro/playbooks/output-verification"}, "alternates": {"html": "https://wpnews.pro/news/how-instagram-detects-ai-images-c2pa-iptc-and-xmp-explained-with-code-to-inspect", "markdown": "https://wpnews.pro/news/how-instagram-detects-ai-images-c2pa-iptc-and-xmp-explained-with-code-to-inspect.md", "text": "https://wpnews.pro/news/how-instagram-detects-ai-images-c2pa-iptc-and-xmp-explained-with-code-to-inspect.txt", "jsonld": "https://wpnews.pro/news/how-instagram-detects-ai-images-c2pa-iptc-and-xmp-explained-with-code-to-inspect.jsonld"}}