Read out EXIF via Python Thursday, January 14, 2010



My requirement is to extract a thumbnail in exif section in a jpeg file.

I have tried exiftool(http://www.sno.phy.queensu.ca/~phil/exiftool/).Exiftool is based on perl,this tool is very powerful and so it's also very very complex.I just want to extract the thumbnail!

After inverstaging, I think the library,exif.py, is prefer.


I followed the belowing to install the package.
1. download library at http://sourceforge.net/projects/exif-py/files/
2. extract it
3. I copied exif.py to Lib folder


Now I'll extact thumbnail. the belowing is a demo.

import EXIF
# extract thumbnail in Exif and save it
f = open("c:\\p2.jpg",'rb')
tags = EXIF.process_file(f)
# save the thumbnail into a jpg format file
f = open("c:\\a.jpg",'wb')
f.write(tags["JPEGThumbnail"])
f.close()