1

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.

ensnare
  • 40,069
  • 64
  • 158
  • 224
  • regarding python and exif, see http://stackoverflow.com/questions/765396/exif-manipulation-library-for-python See [wikipedias](http://en.wikipedia.org/wiki/Exchangeable_image_file_format) entry on exif – Fredrik Pihl Dec 25 '11 at 22:07
  • Depends very heavily on the file type. You can't assume anything about the location of an EXIF unless you know the specific file type and how they encode their information. – mathematical.coffee Dec 25 '11 at 23:38
  • Right -- How can I find out where in the file the exif tag is? I'm assuming it's different for every file type, particularly RAW files. – ensnare Dec 25 '11 at 23:46

1 Answers1

2

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.

jcollado
  • 39,419
  • 8
  • 102
  • 133