TNThieding/exif

string must be no longer than original

Closed this issue · 2 comments

In my use case I would use this module mostly storing certain fields to images. However, when setting a string field, gives the error below.

Do you see any fix or workaround for this. When setting string fields, this kind of restriction makes this pretty much useless when updating field values?

my_image.copyright = vals.get('copyright','')

File "C:\Odoo 12.0\python\lib\site-packages\exif_image.py", line 92, in setattr
setattr(self._segments['APP1'], key, value)
File "C:\Odoo 12.0\python\lib\site-packages\exif_app1_metadata.py", line 238, in setattr
ifd_tag.modify(value)
File "C:\Odoo 12.0\python\lib\site-packages\exif\ifd_tag_ascii.py", line 36, in modify
raise ValueError("string must be no longer than original")
ValueError: string must be no longer than original

Thank you for reaching out, rnurmi! This has been quite a frustrating limitation for a while now. I'm actually currently working on adding support for adding and deleting tags, which will address this use case since modifying strings to a longer value would simply delete and re-add the tag under-the-hood. I'm hoping to have this feature wrapped up within this week or next, so stay tuned! I'll be sure to update this issue when things are released.

Hello, @rnurmi! Version v1.0.0 of the package (released moments ago) adds support for setting ASCII tags beyond their pre-existing length. Please don't hesitate to follow up with a new issue if this fix doesn't work in your use case and/or if anything else needs patched up. (Sample images help recreate errors, so please provide those if possible.)