Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #2278

The issue reports that a TIFF image cannot be opened and saved - AttributeError: 'tuple' object has no attribute 'ljust'. The problem comes from tag 33723 - https://www.awaresystems.be/imaging/tiff/tifftags/iptc.html

33723: ("IptcNaaInfo", UNDEFINED, 0),

Loading and saving existing test image hopper.Lab.tif currently triggers the same bug.

This PR changes the tag length to 1, allowing the image to save without an error.

It also produces nicer values for the tag.

from PIL import Image
im = Image.open("00000001.tif")
print(im.tag_v2[33723])
im = Image.open("Tests/images/hopper.Lab.tif")
print(im.tag_v2[33723])

Currently gives

(b'\x1c\x01Z\x00\x03\x1b%G\x1c\x02\x00\x00\x02\x00\x00\x1c\x02P\x00\tULB Halle\x1c\x02t\x00\r(c) ULB Halle',)
(b'\x1c\x01Z\x00\x03\x1b%G\x1c\x02\x00\x00\x02\xcf\xc0',)

But with this PR, it gives

b'\x1c\x01Z\x00\x03\x1b%G\x1c\x02\x00\x00\x02\x00\x00\x1c\x02P\x00\tULB Halle\x1c\x02t\x00\r(c) ULB Halle'
b'\x1c\x01Z\x00\x03\x1b%G\x1c\x02\x00\x00\x02\xcf\xc0'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'tuple' object has no attribute 'ljust' when trying to save image

2 participants