AlterTrace
EN
← Blog / knowledge

AlterTrace experiment

Does extracting a photo from an email or PDF preserve its EXIF and SHA-256?

We put the same JPEG in two emails and two PDFs. Both emails and the unmasked PDF gave us back the same 6,461 bytes. Adding an opacity mask to the other PDF changed the extracted file to a PNG, even though the original JPEG was still inside the document.

01

What came out of the six files?

Four of the six extracted images matched their source files byte for byte. We compared the SHA-256 of the extracted image with that of the image file before embedding. The container hashes are recorded separately in the dataset.

Each input contained one test image. Dimensions are in pixels. The EXIF count covers the four known tags written into the reference images.
CaseFormat and dimensions before β†’ afterImage SHA-256EXIF tags
01 Β· EML Β· Base64 attachmentJPEG 192 Γ— 128 β†’ JPEG 192 Γ— 128match4 β†’ 4
02 Β· EML Β· quoted-printable attachmentJPEG 192 Γ— 128 β†’ JPEG 192 Γ— 128match4 β†’ 4
03 Β· EML Β· inline PNG, CID + Base64PNG 192 Γ— 128 β†’ PNG 192 Γ— 128match4 β†’ 4
04 Β· PDF Β· standalone JPEGJPEG 192 Γ— 128 β†’ JPEG 192 Γ— 128match4 β†’ 4
05 Β· PDF Β· downsampled RGB, FlatePNG 192 Γ— 128 β†’ PNG 96 Γ— 64different4 β†’ 0
06 Β· PDF Β· JPEG with soft maskJPEG 192 Γ— 128 β†’ PNG 192 Γ— 128different4 β†’ 0
02

Two email sizes, one attachment[2]

The first message was 9,303 bytes and the second was 20,628. We changed how the JPEG bytes were represented inside the MIME part. In the quoted-printable message we encoded every byte as an equals sign followed by two hexadecimal digits. After decoding, both copies had the same SHA-256 and all four EXIF tags. The third email displayed a PNG using a cid: reference to a separate MIME part. All 1,503 bytes of that inline image survived extraction too.

03

A smaller image inside a full-size PDF page

For case 05 we reduced the target from 192 Γ— 128 to 96 Γ— 64 before building the PDF. The document stored only Flate-compressed RGB values, without the PNG header or EXIF. The target still occupied the same area on the page. The extracted PNG measured 96 Γ— 64. Its RGB values matched the downsampled control at every one of its 6,144 pixels. That places the resolution change at PDF creation.

04

The JPEG still had EXIF inside the masked PDF[1][3]

Cases 04 and 06 contained identical JPEG streams, including their EXIF. Case 06 also pointed to a separate /SMask with 192 opacity levels. The extractor combined the image and the mask into a PNG with an alpha channel. All 24,576 alpha values matched the independently stored mask. Compared with the reference JPEG decoded by Pillow, 2,142 pixels differed in RGB, by at most 3, 2 and 3 levels out of 255 in the respective channels. None of the four EXIF tags appeared in the output PNG.

Test target without a maskTest target with a graduated opacity mask
Left: JPEG extracted from PDF 04. Right: PNG extracted from PDF 06. The checkerboard beneath the image makes its transparency visible.
05

How should a claims reviewer compare two copies?

Keep the received message or PDF alongside the full image you downloaded. If the sender can supply their photo file, compare the two image hashes. In case 04 that check confirmed an exact byte match. In case 06 the mismatch is a reason to examine the mask and output format. Missing EXIF in the extracted PNG alone would be a poor basis for inferring retouching. Without a reference file you can report the image properties you observed, but you cannot establish a byte match to the camera file.

06

Repeat the experiment

Unzip the dataset and start with case 04. Run the first command from the dataset directory. Both files should produce the digest below. On macOS use shasum -a 256.

sha256sum references/target.jpg results/04-001-page-1-image.jpg
# 8a44fb0d46b0eac535bfab3d626377f605d11b94aae440fc88f77b139197c109
07

How do I run a fresh extraction?

Open each file from inputs/ in its corresponding AlterTrace tool. Download the full image into a folder named manual/. Prefix each filename with its case number, for example 06-output.png. Run the commands below in an active Python 3.12 environment. Compare the resulting CSV against measurements.csv from the dataset. To measure our archived outputs first, replace manual with results.

python -m pip install Pillow==13.0.0
python scripts/measure.py manual --save my-tables
08

Method and scope

On 30 November 2026 we ran the actual extractEml and extractPdf functions locally at revision 7add41bfb133ccf9eca31036f4234d10c0f825c2. Two separate Node 24.22.3 processes returned identical bytes for each case. Python independently computed SHA-256 and compared the complete files. Pillow 13.0.0 read the format, dimensions and the ImageDescription, Model, Orientation and Software tags. Python’s email parser and PyMuPDF 1.26.6 independently verified the container contents. All pictures were synthetic. The six cases exercise the extraction functions. They do not measure changes introduced by a live mailbox or web interface, or establish the authenticity of a photo.

Sources and references

Sources

  1. 01AlterTrace: fixtures and results, version 1 (ZIP)β†—
  2. 02RFC 2045 §6 · Content-Transfer-Encoding↗
  3. 03W3C · PNG eXIf↗
Frequently asked questions

Frequently asked questions

01Does a different SHA-256 for a photo extracted from a PDF indicate retouching?+

A different digest shows that the two files contain different bytes. In case 06 the extractor saved the masked image as PNG. Establishing retouching would require additional evidence.

02Does an image displayed inside an email keep its metadata?+

Our inline PNG was stored as a MIME part with a Content-ID and retained all four test tags. A picture loaded from an external URL is a different case.

Check your own image

Have an actual file rather than a theoretical problem? Run a multi-layer authenticity analysis.

Check your own image β†—
AlterTracer 2026