A friend was interested in using a script to sort photos based on the year they were taken, this made me start looking into how Python could access photo metadata.

Most options seem to suggest using the library Pillow. Something like https://pillow.readthedocs.io/en/stable/reference/ExifTags.html but I found the simplest option to be using the EXIF library.

More detailed information is @ https://auth0.com/blog/read-edit-exif-metadata-in-photos-with-python/


from exif import Image

#image_path = "E:/Old Pictures/2012-08-05 Birthday 2012/Birthday 2012 037.jpg"
image_path = "E:/Old Pictures/2012-08-16 ipod/ipod 005.JPG"

with open(image_path, "rb") as img_file:
    my_image = Image(img_file)

if my_image.has_exif:
    print("Version: ", my_image.exif_version)
    print(my_image.datetime_original)