Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #3677

This PR has two changes.

Firstly, Pillow currently treats BYTE tags of count N as if they might have N strings. I do not believe this should be the case. To look at count values for character-related tags, the BYTE tag GPSAltitudeRef has count 1 for 1 character, the ASCII tag GPSDateStamp has count 11 for 11 characters, and the UNDEFINED tag Flashpix Version has count 4 for 4 characters. So, I think BYTE tags of count N have N characters, and are only single strings.

Secondly, this PR changes the following current code, to no longer force BYTE tags into ASCII tags.

Pillow/src/encode.c

Lines 732 to 736 in d23df72

if (PyBytes_Check(value) &&
(type == TIFF_BYTE || type == TIFF_UNDEFINED)) {
// For backwards compatibility
type = TIFF_ASCII;
}

This second change was made because in trying to resolve the issue, I found that libtiff was throwing an error for the XMLPACKET tag. It seems reasonable that it would - it is a BYTE tag, and we are instead passing ASCII.

Together, these changes resolve the issue.

@radarhere radarhere added the TIFF label May 3, 2020
@radarhere radarhere force-pushed the byte_tags branch 2 times, most recently from 6cd33e0 to af5be32 Compare May 5, 2020 12:21
@radarhere radarhere changed the title Improved writing of TIFF BYTE tags Improved writing of TIFF BYTE tags, added writing of UNDEFINED tags May 6, 2020
@radarhere radarhere changed the title Improved writing of TIFF BYTE tags, added writing of UNDEFINED tags Writing TIFF tags: improved BYTE, added UNDEFINED May 6, 2020
@radarhere
Copy link
Member Author

I've added another commit to this PR, since they both involve the same code, to resolve #4252. Pillow has been just been skipping UNDEFINED tags when writing with libtiff. This commit adds writing of UNDEFINED tags.

@radarhere radarhere force-pushed the byte_tags branch 2 times, most recently from 06f2a5d to 305bdc6 Compare May 6, 2020 10:15
@hugovk hugovk merged commit 7d9ac36 into python-pillow:master Jun 20, 2020
@radarhere radarhere deleted the byte_tags branch June 20, 2020 12:34
radarhere added a commit to radarhere/Pillow that referenced this pull request Jun 21, 2020
@radarhere radarhere mentioned this pull request Jun 21, 2020
radarhere added a commit to radarhere/Pillow that referenced this pull request Jun 21, 2020
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.

Saving TIFF with compression throws Segmentation Fault 11 in 5.4.1, but not 5.3.0

2 participants