Skip to main content

Module jpeg

Module jpeg 

Source
Expand description

JPEG.

The format most likely to be handed to this tool by someone in danger. A photograph taken on a phone and sent to a newsroom carries, by default, the coordinates it was taken at, the serial number of the device that took it, the moment it was taken to the second, and a thumbnail that predates whatever cropping was done afterwards.

§Segment surgery, never re-encoding

A JPEG is a sequence of marker segments — two-byte marker, two-byte length, payload — wrapped around entropy-coded scan data that holds the actual picture. Everything identifying lives in the APPn and COM segments; none of it lives in the scan data.

So this handler never decodes an image and never re-encodes one. It walks the segment list, drops the segments that carry metadata, and copies the scan data through byte for byte. A decode-and-re-encode round trip would be far less code and would quietly destroy image quality on every pass — for a photojournalist whose picture is the evidence, that is damage, not a side effect (docs/PRD.md §8.1). It would also change the pixels of a file that someone may need to demonstrate is unaltered.

§What is deliberately kept

Two segments survive, and both are reported in the strip report’s retained list rather than left to be noticed:

  • APP0 (JFIF), minus any thumbnail inside it. It carries the pixel aspect ratio, and dropping it silently changes how a non-square-pixel image displays.
  • APP14 (Adobe), which declares the colour transform. A CMYK or YCCK JPEG whose APP14 has been removed is rendered with inverted or wrong colours by many decoders.

Both are fixed-shape structures that name no person, no place, and no device.

§What is removed even though it affects rendering

Exif Orientation and the APP2 ICC colour profile both go. Each changes how the image displays: an image that relied on Orientation may appear rotated afterwards, and a wide-gamut image without its profile is interpreted as sRGB. They are removed anyway, because both are also identifying — a profile routinely names the device or vendor that made it — and because leaving them would make strypt remove less than mat2 does for the same file. The limitation is documented rather than hidden; see CHANGELOG.md.

Structs§

JpegHandler
Removal of metadata from JPEG images.