Skip to content

getiptcinfo() fails to get iptc metadata for TIFF images #8923

@junqfisica

Description

@junqfisica

What did you do?

I'm trying to read IPTC metadata from a TIFF image.
A simple example would be:

from PIL import Image
with Image.open(file_path) as im:
     print(getiptcinfo(im))

What did you expect to happen?

The IPTC metadata output

What actually happened?

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:

data = im.tag.tagdata[TiffImagePlugin.IPTC_NAA_CHUNK]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions