LeoHsiao1 / pyexiv2

Read and write image metadata, including EXIF, IPTC, XMP, ICC Profile.
GNU General Public License v3.0
201 stars 39 forks source link

Iptc.Application2.Keywords problem #18

Closed KosuzuMotoori closed 4 years ago

KosuzuMotoori commented 4 years ago

Iptc.Application2.Keywords returs only one keyword, although there are several keywords in the image.

LeoHsiao1 commented 4 years ago

I haven't used this tag, and I'm trying to assign it:

>>> img.modify_iptc({'Iptc.Application2.Keywords': ['hello', 'world']})
>>> img.read_iptc()['Iptc.Application2.Keywords']
'hello, world'

Do you want it to return a list of string, ['hello', 'world'] ?

KosuzuMotoori commented 4 years ago

The list would be better!

KosuzuMotoori commented 4 years ago
from pyexiv2 import Image
img = Image(r'/photo.jpg')
iptc = img.read_iptc()
print(iptc['Iptc.Application2.Keywords'])
img.close()

from iptcinfo3 import IPTCInfo
info = IPTCInfo('photo.jpg')
print(info['keywords'])

python3 test.py Summer [b'River', b'Boat', b'Sweden', b'Summer']

LeoHsiao1 commented 4 years ago

I will improve the code this weekend.

LeoHsiao1 commented 4 years ago

I've improved the code so that it can read and write duplicate IPTC keys now. I will release a new version in a few days.

Sample:

>>> from pyexiv2 import Image
>>> img = Image(r'.\pyexiv2\tests\1.jpg')
>>> img.modify_iptc({'Iptc.Application2.Keywords': ['tag1', 'tag2', 'tag3']})
>>> img.read_iptc()['Iptc.Application2.Keywords']
['tag1', 'tag2', 'tag3']
>>> img.close()
LeoHsiao1 commented 4 years ago

I have released a new version, v2.2.0, please try it.

KosuzuMotoori commented 4 years ago

Thanks! It works!!!

github-actions[bot] commented 3 years ago

This issue has been automatically closed because there has been no activity for a month.