I use IPTCInfo3 in my Python app to write keywords to the IPCT metadata of an image.
For some reason if I use info.save() it creates a copy of the original, e.g. it will write the keyword to Clean.JPG but will also create Clean.JPG~ without the keywords.
If I use info.save_as('Clean.jpg') instead (try to force it to overwrite the original), it doesn't write the keywords to the file.
Is there a solution to this?
import iptcinfo3
new_keyword = ["cool", "sad", "blah"]
info = iptcinfo3.IPTCInfo('C:/Tmp/IPTCINFO/Clean.JPG')
for keyword in new_keyword:
if keyword.encode('UTF-8') not in info['keywords']:
info['keywords'].append(keyword)
info.save()
This solution worked for me.
You will have to comment out 2 lines in the iptcinfo3.py file inside the "save_as" method around line 695 of the file.
This will write inside the original file without creating a new one and leaving the one with ".jpg~" behind.