Closed Louuu closed 1 year ago
@Louuu thanks for the interest in using this. You have to treat Keywords as a list type, meaning you would append new values, as the example at the bottom of the readme shows.
from iptcinfo3 import IPTCInfo
info = IPTCInfo('/Downloads/testimage.jpg')
print(info['keywords'])
info['keywords'].append('new keyword')
print(info['keywords'])
info.save_as('0_processed.jpg')
works fine and shows that 'new keyword' is added as part of the list of keywords.
Please confirm and I will close this issue. Thanks
@jamesacampbell I have tried that as well.
Upon initially opening the file though I receive the message.
WARNING: problems with charset recognition (b'\x1b')
I can see that info['keywords']
shows the new tags, however, after saving them they don't appear to be visible in any external software.
>>> from iptcinfo3 import IPTCInfo
>>> info = IPTCInfo('broken.jpg')
WARNING: problems with charset recognition (b'\x1b')
>>> print(info['keywords'])
[b'To Blur', b'Party001', b'To Watermark']
>>> info['keywords'].append('new keyword')
>>> print(info['keywords'])
[b'To Blur', b'Party001', b'To Watermark', 'new keyword']
>>> info.save_as('0_processed.jpg')
True
>>> info = IPTCInfo('0_processed.jpg')
>>> print(info['keywords'])
[b'To Blur', b'Party001', b'To Watermark', b'new keyword']
>>>
This only occurs when I'm modifying an image that has existing tags. Images without existing tags don't produce the warning message and work as expected.
@Louuu truly strange. Here is my output on 3.7.7:
>>> info['keywords'].append('new keyword')
>>> info.save_as('0_processed.jpg')
>>> info['keywords'].append(b'new keyword')
>>> print(info['keywords'])
[b'To Blur', b'Party001', b'To Watermark', 'new keyword', b'new keyword']
>>> info.save_as('0_processed.jpg')
True
>>> info = IPTCInfo('0_processed.jpg')
>>> print(info['keywords'])
[b'To Blur', b'Party001', b'To Watermark', b'new keyword', b'new keyword']
So it appears to definitely work on my end. I am not sure what to tell you at this point. Can you try again with 3.7.7 in venv / pipenv using pyenv to get version installed?
So I've setup an environment with 3.7.7 and have tried to add the tags to the image in two different formats. They do get saved in the file. However, upon opening them in any application that shows the tags, they're not visible as shown in the previous message.
A further discovery is that as soon as I update the tags from another app, the two additional ones disappear from the file completely
Example below
Python 3.7.7 (default, Oct 21 2020, 15:15:02)
[Clang 12.0.0 (clang-1200.0.32.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from iptcinfo3 import IPTCInfo
>>> file = IPTCInfo("broken.jpg")
WARNING: problems with charset recognition (b'\x1b')
>>> print(file['keywords'])
[b'To Blur', b'Party001', b'To Watermark']
>>> file['keywords'].append("test")
>>> file['keywords'].append(b"test2")
>>> print(file['keywords'])
[b'To Blur', b'Party001', b'To Watermark', 'test', b'test2']
>>> file.save_as("processed.jpg")
True
>>>
>>> file2 = IPTCInfo("processed.jpg")
>>> print(file2['keywords'])
[b'To Blur', b'Party001', b'To Watermark', b'test', b'test2']
>>>
>>> # after adding tag in preview
>>> file2 = IPTCInfo("processed.jpg")
WARNING: problems with charset recognition (b'\x1b')
>>> print(file2['keywords'])
[b'To Blur', b'Party001', b'To Watermark', b'tag from app']
>>>
The source of the tags on the photos seems to be Synology PhotoStation after speaking with the person who tags them. Upon submitting the tagged photo back, they're not visible that application either.
So this seems to be the case with Preview, Synology PhotoStation and PhotoShop
Here's some screenshots that were sent to me Also, the person in the source photo doesn't mind, he's from https://www.thispersondoesnotexist.com/ :)
@Louuu after investigation, you are using the XMP viewer. That is only one type of IPTC data. There is also IIM. I recommend uploading the photo to this site and checking ALL of the metadata and then checking back here. This is my result. You can see, you did add the keywords there in the IIM and they also exist in the XMP keywords section as well. When you add via iptcinfo, you are adding to the IIM, which is agnostic to Adobe or any other proprietary thing.
closing, as per the solution above shows that you do add the tags to IIM.
When using the code below. I am receiving the error message
WARNING: problems with charset recognition (b'\x1b')
Current version is
IPTCInfo3==2.1.4
The image that I am trying to process is attached
The expected behaviour is that the new image has the new keywords, however the old keywords remain.