Pillow
Pillow copied to clipboard
Handle IPTC TIFF tags with incorrect type
Resolves #8923
#8315 replaced im.tag.tagdata[TiffImagePlugin.IPTC_NAA_CHUNK] with im.tag_v2[TiffImagePlugin.IPTC_NAA_CHUNK], but didn't think to ask why .tagdata was used, rather than just im.tag[TiffImagePlugin.IPTC_NAA_CHUNK]. The answer would have been in this comment.
https://github.com/python-pillow/Pillow/blob/58e48745cc7b6c6f7dd26a50fe68d1a82ea51562/src/PIL/IptcImagePlugin.py#L219-L220
This would have been referring to the same phenomenon as https://web.archive.org/web/20240221164915/https://www.awaresystems.be/imaging/tiff/tifftags/iptc.html
Often times, the datatype is incorrectly specified as LONG.
This fixes the issue by switching to im.tag_v2._tagdata[TiffImagePlugin.IPTC_NAA_CHUNK]