<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->

# API Reference — Metadata Extraction

## ExifTool

### Basic Extraction
```bash
exiftool file.pdf
exiftool -a -u -g1 document.pdf  # All tags, unknown, grouped
```

### JSON Output
```bash
exiftool -j file.pdf
exiftool -j -r ./directory/  # Recursive JSON
```

### CSV Export
```bash
exiftool -r -csv -Author -Creator -Producer -Software -CreateDate ./files/ > report.csv
```

### GPS Extraction
```bash
exiftool -gps* -DateTimeOriginal image.jpg
exiftool -n -GPSLatitude -GPSLongitude image.jpg  # Decimal format
```

### Specific Fields
```bash
exiftool -Author -Creator -Producer -Software -Company file.pdf
exiftool -Make -Model -LensModel photo.jpg
```

### Write/Remove Metadata
```bash
exiftool -all= file.pdf                 # Remove all metadata
exiftool -Author="New Author" file.pdf   # Set metadata
```

## mat2

### Show Metadata
```bash
mat2 --show file.pdf
```

### Strip Metadata
```bash
mat2 file.pdf                # Creates file.cleaned.pdf
mat2 --inplace file.pdf      # Modify in place
```

### Supported Formats
```
PDF, DOCX, XLSX, PPTX, ODT, ODS, ODP, EPUB,
JPEG, PNG, GIF, TIFF, SVG, MP3, MP4, FLAC
```

## pdfinfo

### Basic Info
```bash
pdfinfo document.pdf
```

### Output Fields
```
Title, Author, Creator, Producer, CreationDate, ModDate, Pages, Encrypted
```

## Python Libraries

### Pillow (Images)
```python
from PIL import Image
from PIL.ExifTags import TAGS

img = Image.open("photo.jpg")
exif = img._getexif()
if exif:
    for tag_id, value in exif.items():
        tag = TAGS.get(tag_id, tag_id)
        print(f"{tag}: {value}")
```

### PyPDF2 (PDFs)
```python
from PyPDF2 import PdfReader
reader = PdfReader("document.pdf")
meta = reader.metadata
print(f"Author: {meta.author}")
print(f"Creator: {meta.creator}")
print(f"Producer: {meta.producer}")
```

### python-docx (Word Documents)
```python
from docx import Document
doc = Document("file.docx")
props = doc.core_properties
print(f"Author: {props.author}")
print(f"Last Modified By: {props.last_modified_by}")
print(f"Created: {props.created}")
```

## Metagoofil

### Harvest and Extract
```bash
metagoofil -d example.com -t pdf,docx,xlsx -l 200 -o files/
```

## Environment Variables

| Variable | Description |
|----------|-------------|
| None required | All tools work with local files |
