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:

1. Where Images Hide Metadata (JPEG, PNG, and WebP Map)

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

2. Decoding EXIF GPS, Multi-Chunk ICC, and ComfyUI / A1111 Prompts

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:

  • Pure-JS zlib inflation: PNG 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.
  • ComfyUI (prompt & workflow): Parses JSON node maps checking 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.
  • Stable Diffusion / A1111, NovelAI & Midjourney: Splits A1111 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:.
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 

3. Lossless Container Invariants & Formula-Safe Audit Exports

Rewriting binary images safely requires three strict checks:

  1. JPEG progressive scan safety: At 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.
  2. PNG IEEE CRC32 recomputation: Stripping chunks requires an allowlist (IHDR, PLTE, tRNS, IDAT, IEND, plus optional color chunks) and recalculating each chunk's 4-byte CRC32 over [type + data].
  3. WebP odd-byte RIFF padding & VP8X cleanup: Odd-length RIFF payloads require a trailing zero pad byte, and removing EXIF or XMP must clear bits 0x10 and 0x08 in VP8X (collapsing VP8X entirely back to RFC 9649 Simple WebP when no 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.

4. Factual C2PA, GDPR, and SynthID Boundaries

  • Risk grading & GDPR minimization: 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.
  • Container presence vs. cryptographic trust: Scanning APP11, caBX, WebP C2PA/JUMB, and XMP detects JUMBF containers and claim hints (c2pa.claim, trainedAlgorithmicMedia), not X.509/COSE trust signature verification.
  • Metadata vs. invisible pixel watermarks: Binary container stripping never alters pixel values, so it does not remove invisible pixel-level watermarks such as Google SynthID, and removing metadata does not exempt publishers from applicable AI disclosure requirements.

Try the Workbench or Clone the MIT Core