VaultDocs
6 min read

Scrub EXIF and Metadata From Scanned Documents Completely

Remove hidden EXIF data, XMP metadata, and device fingerprints from scanned PDFs and images using offline tools. Step-by-step guide.

Scanned documents carry more information than the visible page. Your scanner embeds device serial numbers, timestamps, GPS coordinates (if scanning from a phone), software versions, and sometimes even your username into every file it produces. This metadata persists through most file operations and survives basic redaction attempts.

When you share a scanned document, you may inadvertently reveal when you scanned it, what device you used, your operating system, and potentially your location. For sensitive documents—legal filings, medical records, financial statements—this leakage creates unnecessary risk.

This guide covers how to identify and remove metadata from scanned documents using local tools that never touch the internet.

What metadata hides in scanned documents

Scanned documents typically exist as PDFs containing embedded images, or as standalone image files (TIFF, JPEG, PNG). Each format carries different metadata types:

Image-level metadata (EXIF/XMP):

  • Camera or scanner make and model
  • Serial numbers
  • Scan date and time
  • Software used for scanning
  • Color profiles
  • GPS coordinates (common with phone scans)
  • Thumbnail images (sometimes containing unredacted previews)

PDF-level metadata:

  • Author name (often your OS username)
  • Creator application
  • Producer application
  • Creation and modification timestamps
  • Title, subject, keywords
  • XMP metadata blocks (can duplicate or extend the above)
  • Document ID (unique identifier that persists across copies)

Hidden structural data:

  • Incremental save history
  • Deleted objects still present in the file
  • Multiple image layers
  • OCR text layers (if OCR was applied)

A document that looks like a simple scanned page may contain dozens of metadata fields identifying you and your equipment.

Why standard redaction misses metadata

Drawing black boxes over sensitive content addresses only the visible layer. Metadata lives in file headers and embedded streams—completely separate from what you see on the page. Even "Save As" operations typically preserve most metadata intact.

Common failures:

  1. Redacting the image but not the PDF wrapper: You strip EXIF from the embedded JPEG, but the PDF still contains your username in the Author field.

  2. Flattening without scrubbing: Flattening merges visible layers but doesn't touch metadata fields.

  3. Using "Remove Hidden Data" partially: Some tools remove PDF metadata but leave EXIF data inside embedded images untouched.

  4. Forgetting thumbnails: EXIF thumbnails can contain the original unredacted image in miniature.

Complete sanitization requires addressing both the container (PDF) and its contents (embedded images).

Tools for offline metadata removal

exiftool (cross-platform)

The most comprehensive metadata inspection and removal tool available. Handles EXIF, IPTC, XMP, and dozens of other formats.

Installation:

  • macOS: brew install exiftool
  • Linux: sudo apt install libimage-exiftool-perl
  • Windows: Download from exiftool.org (standalone executable)

Inspect metadata:

exiftool -a -G1 scanned_document.pdf

The -a flag shows duplicate tags, -G1 groups them by location.

Remove all metadata from images:

exiftool -all= scanned_image.jpg

Remove all metadata from PDF:

exiftool -all:all= document.pdf

Preserve only essential structural data:

exiftool -all:all= -tagsfromfile @ -pdf:all document.pdf

mat2 (Linux/macOS)

Metadata Anonymisation Toolkit 2—designed specifically for privacy-focused metadata removal. Supports PDFs, images, Office documents, and audio/video files.

Installation:

# Debian/Ubuntu
sudo apt install mat2

# macOS
brew install mat2

Check what metadata exists:

mat2 --show document.pdf

Clean the file:

mat2 document.pdf

mat2 creates a cleaned copy with .cleaned appended to the filename. It's conservative by default, removing metadata while preserving document functionality.

qpdf (PDF-specific)

Handles PDF structure, linearization, and can strip certain metadata during rewrite operations.

Linearize and rewrite (removes some cruft):

qpdf --linearize input.pdf output.pdf

Remove encryption and reprocess:

qpdf --decrypt --object-streams=generate input.pdf output.pdf

qpdf alone doesn't remove all metadata—pair it with exiftool for complete coverage.

Ghostscript (nuclear option)

Re-renders the PDF through PostScript, effectively creating a new document. Destroys all metadata, layers, and hidden content.

gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
   -dCompatibilityLevel=1.4 \
   -sOutputFile=clean.pdf input.pdf

This approach is thorough but may slightly alter appearance or reduce quality. It's appropriate when you need certainty over fidelity.

Step-by-step sanitization workflow

For scanned images (JPEG, TIFF, PNG)

  1. Inspect current metadata:

    exiftool -a -G1 scan.jpg
    
  2. Remove all metadata:

    exiftool -all= scan.jpg
    
  3. Verify removal:

    exiftool scan.jpg
    

    Output should show only basic file properties (size, dimensions, format).

  4. Check for embedded thumbnails (JPEG):

    exiftool -ThumbnailImage -b scan.jpg > thumb.jpg
    

    If this produces a file, the thumbnail existed. Re-run removal if needed.

For scanned PDFs

  1. Extract and inspect embedded images:

    pdfimages -list document.pdf
    
  2. Check PDF-level metadata:

    exiftool -a -G1 document.pdf
    
  3. Remove PDF metadata:

    exiftool -all:all= document.pdf
    
  4. For embedded image metadata, use mat2:

    mat2 document.pdf
    
  5. For maximum sanitization, re-render with Ghostscript:

    gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
       -sOutputFile=sanitized.pdf document.pdf
    
  6. Final verification:

    exiftool sanitized.pdf
    mat2 --show sanitized.pdf
    

Handling OCR text layers

If your scanner applied OCR, the PDF contains a hidden text layer. This layer may include text you intended to redact visually but forgot exists as selectable content.

Check for text layers:

pdftotext document.pdf - | head -50

If this outputs readable text from a "scanned" document, an OCR layer exists.

Remove OCR layers by re-rendering as image-only:

pdftoppm document.pdf page -png
convert page-*.png no_ocr.pdf

This creates a true image-only PDF with no hidden text. See our guide on How to Flatten a PDF to Remove Hidden Layers Securely for detailed approaches.

Verify your work

Never trust that sanitization worked—verify independently.

Multi-tool verification:

# Check with exiftool
exiftool -a -G1 sanitized.pdf

# Check with mat2
mat2 --show sanitized.pdf

# Check for hidden text
pdftotext sanitized.pdf - | wc -w

# Inspect PDF structure
qpdf --check sanitized.pdf

Manual inspection: Open the file in a hex editor or run strings sanitized.pdf | grep -i username (substitute your actual username) to catch any remaining identifying strings.

Compare file sizes: A properly sanitized file is often smaller. If your "cleaned" file is the same size or larger, metadata may remain.

Our guide on How to Check a PDF for Hidden Metadata covers verification techniques in depth.

Key takeaways

  • Scanned documents contain device fingerprints, timestamps, usernames, and potentially GPS coordinates in metadata fields invisible during normal viewing
  • Visual redaction (black boxes) does not affect metadata—these are separate data structures
  • Use exiftool for inspection and removal across all file types; mat2 for automated privacy-focused cleaning
  • PDFs require sanitizing both the container metadata and embedded image metadata
  • OCR text layers create hidden selectable text that survives visual redaction
  • Ghostscript re-rendering provides the most thorough sanitization when fidelity loss is acceptable
  • Always verify with multiple tools after sanitization—never assume success

For broader document sanitization workflows, see our Free Local PDF Metadata Scrubber: A Complete Guide and Remove Hidden Data From a PDF Before Sending It.

Keep reading