This article describes the library usage that Python uses to get image EXIF information. Share to everyone for your reference. The specific analysis is as follows:
Exif-py is a pure Python implementation of the capture image metadata of the Python library, the official download address:
Http://exif-py.svn.sourceforge.net/viewvc/exif-py/source/EXIF.py?revision=19&view=markup
The following code shows the calling method.
Copy Code code as follows:
# library Test/debug function (dump given files)
if __name__ = = ' __main__ ':
Import Sys
Import getopt
# Parse command line options/arguments
Try
opts, args = Getopt.getopt (sys.argv[1:], "hqsdt:v", ["Help", "quick", "strict", "Debug", "stop-tag="])
Except Getopt. Getopterror:
Usage (2)
if args = = []:
Usage (2)
Detailed = True
Stop_tag = ' UNDEF '
debug = False
Strict = False
For O, a in opts:
If O in ("H", "--help"):
Usage (0)
If o in ("Q", "--quick"):
Detailed = False
If o in ("T", "--stop-tag"):
Stop_tag = A
If O in ("-S", "--strict"):
Strict = True
If o in ("D", "--debug"):
debug = True
# output info for each file
For filename in args:
Try
File=open (filename, ' RB ')
Except
print '%s ' is unreadable\n '%filename
Continue
Print filename + ': '
# Get the tags
data = process_file (file, Stop_tag=stop_tag, details=detailed, Strict=strict, Debug=debug)
If not data:
print ' No EXIF information found '
Continue
X=data.keys ()
X.sort ()
For I in x:
If I in (' Jpegthumbnail ', ' Tiffthumbnail '):
Continue
Try
Print '%s (%s):%s '% \
(I, field_types[data[i].field_type][2], data[i].printable)
Except
print ' Error ', I, ' "', Data[i], '" '
If ' Jpegthumbnail ' in data:
print ' File has JPEG thumbnail '
Print
I hope this article will help you with your Python programming.