Reputation: 42053
In Python, how can I find out where in an image file the EXIF tag is located? I'm assuming it's in the beginning of the file, but I have some proprietary image formats and want to make sure this is always the case. Thanks.
Upvotes: 1
Views: 248
Reputation: 387
The EXIF signature is always big-endian (Apple, Motorola) orientation. The location can float in the JPG header, depending on if a JFIF or true EXIF format. Search specifically for Exif,0,0 exact case with two trailing zeros. This is the signature. The TIFF Header immediately follows the signature. All interop record Value offsets are relative to the TIFF Header.
Upvotes: 0
Reputation: 40394
That depends not only on EXIF iself, but also in the file type.
I assume that you're interested in JPEG files, so looking at the wikipedia page I see the following paragraph:
Strictly speaking, the JFIF and Exif standards are incompatible because they each specify that their marker segment (APP0 or APP1, respectively) appears first. In practice, most JPEG files contain a JFIF marker segment that precedes the Exif header. This allows older readers to correctly handle the older format JFIF segment, while newer readers also decode the following Exif segment, being less strict about requiring it to appear first.
Hence, at least for JPEG files, you might find some images in which the Exif header doesn't appear at the beggining of the file.
Upvotes: 2