Cannot add user comment to images without any prexisting metadata
data = {'test':'1'}
with open(IMAGE_PATH, 'rb') as f:
exif_im = exif.Image(f)
# add exif data
exif_im.set('user_comment', json.dumps(data))
with open(IMAGE_PATH, 'wb') as f:
f.write(exif_im.get_file())
Traceback (most recent call last):
File "faces.py", line 65, in <module> exif_im.set('user_comment', json.dumps(data))
File "C:\Users\MK\miniconda3\lib\site-packages\exif\_image.py", line 185, in set self.__setattr__(attribute, value)
File "C:\Users\MK\miniconda3\lib\site-packages\exif\_image.py", line 87, in __setattr__ setattr(self._segments['APP1'], key, value)
KeyError: 'APP1'
It's possible I'm doing something wrong. Help would be appreciated
Edited by Manav Kulshrestha