LeoHsiao1 / pyexiv2

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

Unable to decode the IPTC image #63

Closed yhfudev closed 3 years ago

yhfudev commented 3 years ago

https://www.iptc.org/std-dev/photometadata/examples/google-licensable/images/IPTC-GoogleImgSrcPmd_testimg01.jpg

LeoHsiao1 commented 3 years ago

I'm trying to read your image:

>>> img = pyexiv2.Image(r'C:\Users\Leo\Desktop\IPTC-GoogleImgSrcPmd_testimg01.jpg')
>>> img.read_iptc()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 0: invalid start byte

By default, pyexiv2 reads and writes images in UTF-8 encoding. If it fails, you can try another encoding, for example:

>>> img.read_iptc('ISO-8859-1')
{'Iptc.Application2.SpecialInstructions': 'This photo is for metadata testing purposes only', 'Iptc.Application2.DateCreated': '2020-01-08', 'Iptc.Application2.TimeCreated': '13:30:01+01:00', 'Iptc.Application2.Byline': ['Jane Photosty'], 'Iptc.Application2.Headline': 'The railway and the cars', 'Iptc.Application2.Credit': 'IPTC/Jane Photosty', 'Iptc.Application2.Copyright': '© Copyright 2020 IPTC (Test Images) - www.iptc.org', 'Iptc.Application2.Caption': 'The railways of the S45 line are running very close to a small street with parking cars', 'Iptc.Application2.RecordVersion': '4'}

The character with the special encoding format seems to be this:

©
github-actions[bot] commented 2 years ago

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