You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
getiptcinfo() fails to get iptc metadata for TIFF images #8923
A TypeError saying a bytes-like object is required, not 'int'
What are your OS, Python and Pillow versions?
OS: Windows 10
Python: 3.12
Pillow: 11.0.0
An image that reproduces the error can be found here: test_iptc_metadata.zip. The IPTC metadata in this image was created using both GIMP and Photoshop. However, neither application’s metadata is handled correctly in Pillow version 11.0.0.
This issue does not occur in Pillow version 10.4.0, where the metadata is processed as expected. The problem was likely introduced by a change made in the following line of code, which now returns an int type instead of a bytes type, leading to the error mentioned above.
Previously, in versions before 11.0.0, the line was:
changed the title [-]Method getiptcinfo() fails to get iptc metadata for tif images.[/-][+]getiptcinfo() fails to get iptc metadata for TIFF images[/+]on Apr 23, 2025
@radarhere Thank you for your quick reply and the info.
That's interesting about the tag type; however, we have no control over it since the metadata comes from scanners or is added via Photoshop. :). Thank you for your PR fixing this issue.
Activity
[-]Method getiptcinfo() fails to get iptc metadata for tif images.[/-][+]getiptcinfo() fails to get iptc metadata for TIFF images[/+]radarhere commentedon Apr 23, 2025
Hmm. The change you're referring to comes from #8315. I tested the change against https://github.com/python-pillow/Pillow/blob/main/Tests/images/hopper.Lab.tif, and it works fine with this because that image specifies the tag type as UNDEFINED.
Your image specifies the tag type as LONG. Interestingly, according to https://web.archive.org/web/20240221164915/https://www.awaresystems.be/imaging/tiff/tifftags/iptc.html, this is a mistake that is often made.
radarhere commentedon Apr 24, 2025
I've created #8925
If you'd like an immediate fix, I find that
works.
junqfisica commentedon Apr 24, 2025
@radarhere Thank you for your quick reply and the info.
That's interesting about the tag type; however, we have no control over it since the metadata comes from scanners or is added via Photoshop. :). Thank you for your PR fixing this issue.