Digital photos often contain extra textual metadata, for example, timestamps, exposure information, and geolocations. Some of this metadata is editable by the camera owner. In the context of marketing, for instance, it can be useful to extract the metadata from profile (or other) images on social media websites. Purportedly, whistle blower Edward Snowden claimed that the American NSA is collecting EXIF metadata from global online data.
In this recipe, we will use ExifRead to extract the EXIF metadata.
Install ExifRead as follows:
$ pip install ExifRead
I tested the code with ExifRead 2.1.2.
The imports are as follows:
import exifread import pprint
Open the image as follows:
f = open('covers.jpg', 'rb')
Print the tags and keys as follows:
# Return Exif tags tags = exifread.process_file(f) print(tags.keys()) pprint.pprint(tags) f.close()
Refer to the following end result:
dict_keys(['EXIF Flash', 'Image Make', 'EXIF Contrast', 'EXIF DateTimeOriginal...