01

JPEG is a container of segments

A JPEG begins with a start marker and continues through variable-length segments until the scan data. Safe parsers validate every declared length before moving to the next segment.

Key points
  • APP1: EXIF or XMP
  • APP2: ICC profile
  • APP13: Photoshop/IPTC resources
  • COM: comments
  • SOS: start of compressed scan data
02

Cleaning without recompression

A segment-level cleaner can remove privacy metadata while copying compressed scan bytes unchanged. Color profiles and orientation deserve special handling because removing them can alter appearance.

03

Follow markers instead of searching for text

Reliable JPEG parsing walks from marker to marker using declared segment lengths. Searching the whole file for words such as GPS or Photoshop can produce false matches inside compressed data and can miss structured binary values.

After the start-of-scan marker, entropy-coded bytes follow different escaping rules. A cleaner must not treat arbitrary bytes there as normal metadata markers or it can corrupt the image.

Key points
  • SOI starts the file
  • APP markers carry common metadata
  • SOS begins scan data
  • EOI closes the image
04

What the controlled segment test demonstrated

The fixture placed EXIF/XMP, ICC, IPTC and compressed scan regions in one small deterministic container. Privacy cleaning removed the selected APP1 and APP13 segments, kept APP2 color data, and left the scan region unchanged.

The test supports the specific segment-level path. It does not imply that every JPEG variant is safe to rewrite: hierarchical, arithmetic-coded, damaged or unusual multi-scan files should be rejected or handled only by a parser that explicitly supports them.

05

Decide between privacy and archival needs

EXIF and IPTC can include both sensitive and valuable information. A public derivative may not need GPS, owner details or editorial notes, while an archival master may depend on captions, rights and provenance.

Keep the master unchanged. Clean a copy, preserve the ICC profile when color matters, and verify the final marker inventory. If C2PA data is present, expect modification to affect credential validation and check it before and after.

What this does not prove

A metadata result describes the fields and structures that the supported parser could read. It does not, by itself, prove authenticity, intent, authorship or the truth of the visible scene.

Sources