TNThieding / exif

Read and modify image EXIF metadata using Python.
https://gitlab.com/TNThieding/exif
MIT License
52 stars 7 forks source link

Handling of arbitrary tag IDs #10

Open gilesknap opened 5 years ago

gilesknap commented 5 years ago

If exif encounters tag IDs not listed in _constants.py then it cannot view them.

For example:- example image

with open('/home/hgv27681/Downloads/IMG_20190317_104705.jpg', 'rb') as image_file:
                ex = exif.Image(image_file)
for tag in dir(ex):
    try:
        print(tag, end=':  '),
        print(ex.get(tag))
    except (RuntimeError, ValueError) as e:
        print('!!! failed:', e)

<unknown EXIF tag 269>:  None
_exif_ifd_pointer:  294
_gps_ifd_pointer:  8492
...

exif ID 269 is Exif.Image.DocumentName.

DocumentName could be added to _constants, but since some camera manufacturers may create their own custom tags, it is perhaps best to support 'unknown' tags.

Maybe an additional function like Image.getById(Id: int) -> Any would work?

TNThieding commented 5 years ago

Great idea, I plan on also including Image.setById() in this delivery as well.

lightheaded commented 4 years ago

Would this also allow reading proprietary tags that are readable via exiftool binary, e.g.:

$ exiftool DJI_0001.JPG
...
Gimbal Roll Degree              : +0.00
Gimbal Yaw Degree               : -120.20
Gimbal Pitch Degree             : -33.60
...
TNThieding commented 4 years ago

@lightheaded, I am not sure about your particular use case with gimbal roll, yaw, and pitch. Could you please provide a sample image so that I can investigate these tags and add support to the package if they aren't supported already?

lightheaded commented 4 years ago

Sure, here's an example image taken by a DJI Mavic 2 Pro: DJI_0332

TNThieding commented 4 years ago

@lightheaded , I finally had a chance to look at your sample image and notices that those tags are encoded in XMP format. Although they're different than EXIF tags, I think I'll add support for XMP tags to this package. I plan on developing a prototype of this functionality in the next week or two using your drone tags.