Get date and time when photo was taken from EXIF data using PIL

sashoalm picture sashoalm · Apr 14, 2014 · Viewed 36.6k times · Source

I can get the EXIF data from an image using PIL, but how can I get the date and time that the photo was taken?

Answer

sashoalm picture sashoalm · Apr 14, 2014

Found the answer eventually, the tag I needed was 36867:

from PIL import Image
def get_date_taken(path):
    return Image.open(path).getexif()[36867]