Handle IPTC TIFF tags with incorrect type by radarhere · Pull Request #8925 · python-pillow/Pillow

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.

# get raw data from the IPTC/NAA tag (PhotoShop tags the data
# as 4-byte integers, so we cannot use the get method...)

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]