hMatoba / Piexif

Exif manipulation with pure python script.
MIT License
367 stars 81 forks source link

piexif.ExifIFD["DateTimeOriginal"] should be also supported #139

Open step135 opened 1 year ago

step135 commented 1 year ago

There is a need to get EXIF data according to value of a variable, but it is not currently achievable:

a = "DateTimeOriginal"
piexif.ExifIFD[a]

It fails!

a = "DateTimeOriginal"
piexif.ExifIFD.get(a)

It also fails!

RezaOptimotive commented 1 year ago

here you can see the full list of available tags.

For your case however, you can do:

exif_dict = piexif.load("foo.jpg")
datetime_original = exif_dict["Exif"][piexif.ExifIFD.DateTimeOriginal]
Dobatymo commented 1 year ago

@step135 you can use getattr(piexif.ExifIFD, "DateTimeOriginal")