# Hidden Metadata in JPEG, PNG, and WebP: EXIF GPS, ComfyUI Prompts, and C2PA Markers Explained (2026)

> Source: <https://dev.to/apps66/hidden-metadata-in-jpeg-png-and-webp-exif-gps-comfyui-prompts-and-c2pa-markers-explained-2026-43nf>
> Published: 2026-12-06 13:08:50+00:00

**Key takeaway:** Parsing and stripping metadata at the container byte level (JPEG APP segments, PNG chunks, WebP RIFF chunks) removes EXIF/GPS, AI prompt chunks and C2PA markers without recompressing pixels, preserving ICC profiles and animated frames.

Uploading a private photo or unreleased AI asset to a remote server just to check whether it leaks GPS coordinates defeats the point of privacy hygiene. Traditional server-side metadata tools commonly retain uploads for 24 to 72 hours while running backend binaries. On the other hand, scrubbing EXIF tags by drawing onto an HTML5 `<canvas>` introduces JPEG recompression artifacts, alters PNG compression, drops wide-gamut ICC profiles, or flattens animated WebP frames.

We built a **100% browser-local image metadata inspector and lossless binary stripper** in pure ESM JavaScript that operates directly on `Uint8Array` container bytes with zero network uploads:

`.ZIP` download, and multi-file CSV/JSON audit reports)
Parsing and cleaning containers at the byte level keeps compressed pixel streams intact while discarding only metadata segments and chunks:

| Format | Magic Bytes | Metadata Containers Parsed | Lossless Binary Stripper Behavior | 
|---|---|---|---|
| **JPEG** | `FF D8` | `APP1` (`Exif\0\0` IFDs, XMP XML),`APP2` (multi-chunk`ICC_PROFILE` ),`APP11` (JUMBF/C2PA),`APP13` (`8BIM` IPTC),`COM` | Drops `APP1..APP15` and`COM` while preserving stuffed`FF 00` entropy scans and restart markers; optional`preserveIcc` keeps`APP2` ICC chunks | 
| **PNG** | `89 50 4E 47 0D 0A 1A 0A` | `tEXt` ,`zTXt` (zlib),`iTXt` (UTF-8 / zlib),`eXIf` ,`iCCP` ,`pHYs` ,`tIME` ,`caBX` (C2PA JUMBF) | Keeps strictly `IHDR` ,`PLTE` ,`tRNS` ,`IDAT` ,`IEND` (plus optional`iCCP` /`sRGB` /`gAMA` ) and recalculates IEEE 802.3`CRC32` (`0xedb88320` ) | 
| **WebP** | `RIFF....WEBP` | `VP8X` bitmasks (`0x40` ICC,`0x20` Alpha,`0x10` EXIF,`0x08` XMP,`0x04` ANIM),`EXIF` ,`XMP` ,`ICCP` ,`C2PA` ,`JUMB` | Drops `EXIF` ,`XMP` ,`C2PA` ,`JUMB` (and`ICCP` unless kept), clears`VP8X` flags, keeps RIFF odd-byte padding, and updates`RIFF` size | 

EXIF uses identical TIFF IFD layouts across JPEG `APP1`, PNG `eXIf`, and WebP `EXIF`. Checking the `II` (`0x4949`) or `MM` (`0x4d4d`) byte-order marker and walking `IFD0`, `ExifIFD` (`0x8769`), and `GPS IFD` (`0x8825`) with cycle protection surfaces camera serial numbers (` BodySerialNumber`, `LensSerialNumber`), `UserComment` text, and rational DMS GPS coordinates (`degrees + minutes / 60 + seconds / 3600`, negated for `S`/` W` refs and below-sea-level altitude).

AI image generators rarely use standard EXIF tags; instead they serialize prompts into PNG text chunks:

`zTXt` chunks and compressed `iTXt` chunks (`compFlag === 1`) use RFC 1950/1951 Deflate streams. To stay dependency-free across browser and Node runtimes, the library embeds a synchronous `inflateZlib()` decoder handling stored blocks, fixed Huffman tables, and dynamic Huffman trees with a 16 MB guard.`prompt` & `workflow`):` class_type` to collect model/LoRA/VAE filenames (`ckpt_name`, `unet_name`, `model_name`, `lora_name`, `vae_name`), `KSampler` parameters (`seed`, `steps`, `cfg`, `sampler_name`, `scheduler`), CLIP prompt strings, and graph node/link counts.` parameters` (and EXIF `UserComment`) on `Negative prompt:` and `Steps:`, extracts NovelAI `Software` + JSON `Comment` metadata, and catches Midjourney `Description` flags (`--ar`, `--v`) plus `Job ID:`.

``` js
import {
  inspectImageMetadata,
  stripImageMetadata,
  auditToMarkdown,
  auditToCsv,
} from 'image-metadata-inspector-core';

// 1. Inspect JPEG, PNG, or WebP bytes completely in-memory
const audit = inspectImageMetadata(uint8Bytes, 'studio-render.png');
console.log({
  riskGrade: audit.riskGrade,
  gps: audit.gps,
  aiGenerators: audit.aiMetadata.generators,
  comfyModels: audit.aiMetadata.comfyUi?.models || [],
  c2paDetected: audit.c2pa.detected,
});

// 2. Losslessly drop EXIF, GPS, XMP, AI chunks, and C2PA while preserving ICC color profile
const cleaned = stripImageMetadata(uint8Bytes, { preserveIcc: true });

// 3. Export pipe-escaped Markdown or formula-safe RFC 4180 CSV
const mdReport = auditToMarkdown([audit]);
const csvReport = auditToCsv([audit]);
```

You can also run audits or clean directories from the terminal using the bundled zero-dependency CLI:

```
npx image-metadata-inspector inspect photo.jpg render.png --json
npx image-metadata-inspector strip photo.jpg photo.clean.jpg
npx image-metadata-inspector strip render.png render.strict.png --drop-icc
```

Rewriting binary images safely requires three strict checks:

`SOS` (`0xDA`), `findEntropyScanEnd()` advances across byte-stuffed `FF 00` pairs and restart markers (`FF D0..FF D7`) so progressive multi-scan JPEGs survive intact while trailing post-`EOI` bytes are stripped.`IHDR`, `PLTE`, `tRNS`, `IDAT`, `IEND`, plus optional color chunks) and recalculating each chunk's 4-byte `CRC32` over `[type + data]`.` EXIF` or `XMP` must clear bits `0x10` and `0x08` in `VP8X` (collapsing `ICC`, `Alpha`, or `Animation` flags remain).
Finally, metadata fields inside third-party files are untrusted strings. Opening unescaped `dc:creator` values or filenames like `=HYPERLINK(...)` in Excel risks CSV formula injection. `auditToCsv()` neutralizes any value starting with `=`, `+`, `-`, `@`, `\t`, or `\r` (including after leading whitespace) with a leading single quote before RFC 4180 quoting.

`gradePrivacyRisk()` flags GPS coordinates, creator/device serial PII, ComfyUI/SD prompt leaks, and C2PA markers as `HIGH`, camera/software/timestamps as `MEDIUM`, and clean containers (including ICC-only images) as `CLEAN`. Client-side processing ensures sensitive coordinates never touch remote infrastructure.`APP11`, `caBX`, WebP `C2PA`/` JUMB`, and XMP detects JUMBF containers and claim hints (` c2pa.claim`, `trainedAlgorithmicMedia`), not X.509/COSE trust signature verification.
