Parsing EXIF metadata – exif_parser.py

The exif_parser plugin is the first we'll develop and is relatively simple due to our reliance on the PIL module. There are three functions within this script: exif_parser(), get_tags(), and dms_to_decimal(). The exif_parser() function, on line 39, is the entry point into this plugin and takes a string representing a filename as its only input. This function primarily serves as coordinating logic for the plugin.

The get_tags() function on line 62 is responsible for parsing the EXIF tags from our input file. Finally, the dms_to_decimal() function on line 172 is a small helper function, which is responsible for converting GPS coordinates into decimal format. Take a look at the following code:

001 from datetime import datetime
002 import os
003 from time import gmtime, strftime
004
005 from PIL import Image
006
007 import processors ... 039 def exif_parser(): ... 062 def get_tags(): ... 172 def dms_to_decimal():