Nitesh Chordiya
Nitesh Chordiya

Reputation: 21

Does Exif metadata always get stored just after the JFIF header?

In JPEG files, Does the exif metadata always gets stored as the first marker? Or can it be in between other markers?

The following has a comment that "After the APP1 Marker area, the other JPEG Markers follow." http://www.media.mit.edu/pia/Research/deepview/exif.html Is it confirmed?

Upvotes: 2

Views: 2610

Answers (2)

Grayson Lang
Grayson Lang

Reputation: 164

There are two common types of JPEG files: JPEG/JFIF and JPEG/Exif.

Both specs (JFIF and Exif) require that their corresponding header appears directly after the SOI (Start of Image) marker.

In the case of JFIF it is an APP0 marker, in the case of Exif it is an APP1 marker.

It is possible to have a JPEG/JFIF file with an Exif block somewhere later in the file. I've noticed that this happens when exporting a JPEG/Exif file from iPhoto. iPhoto ends up converting it into a JPEG/JFIF file, but retains the Exif metadata somewhere later in the file.

However, beyond the requirement that the header for the corresponding file format must come first, there is no restriction on ordering of other APP# marker blocks in the file. Therefore the Exif block can happen at an arbitrary position in a JPEG/JFIF file.

Upvotes: 1

jayarjo
jayarjo

Reputation: 16726

Specs (http://www.exif.org/Exif2-2.PDF) say that - yes - APP1 must come first, right after SOI (ffd8), but sometimes APP0 (JFIF) comes first, right before APP1. It cannot be considered as proper usage, since both specs - JFIF and EXIF state that corresponding markers should immediately follow SOI. But on practice it turns out that such cases happen pretty often, and image editors and viewers interpret such "non-proper" hybrid files correctly.

Upvotes: 2

Related Questions