Search code examples
pythonimageexif

Where in an image is the exif tag located?


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.


Solution

  • 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.