Support writing LONG8 offsets in AppendingTiffWriter#8417
Merged
hugovk merged 3 commits intopython-pillow:mainfrom Oct 12, 2024
Merged
Support writing LONG8 offsets in AppendingTiffWriter#8417hugovk merged 3 commits intopython-pillow:mainfrom
hugovk merged 3 commits intopython-pillow:mainfrom
Conversation
Yay295
reviewed
Sep 25, 2024
| offset = self._read(field_size) | ||
| offset += self.offsetOfNewPage | ||
| if isShort and offset >= 65536: | ||
| if field_size == 2 and offset >= 65536: |
Contributor
There was a problem hiding this comment.
There should probably now also be a check for field_size == 4 and offset >= 2**32.
Member
Author
There was a problem hiding this comment.
It is conceivable that some users might not wish for us to silently upgrade tags to the LONG8 type, since it would be changing the saved image to rely on the BigTIFF specification.
Member
Author
There was a problem hiding this comment.
I've added this functionality to #8663, provided the image is being saved as a BigTIFF.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pillow/Tests/test_file_tiff.py
Lines 110 to 116 in 3f24276
if you try and run the test without removing this tag, an error is raised from
AppendingTiffWriter.Extending
AppendingTiffWriterto handle LONG8 offsets is made complicated as it explicitly only handles shorts and longs, and has duplicated code to achieve that.Pillow/src/PIL/TiffImagePlugin.py
Lines 2143 to 2151 in 3f24276
Pillow/src/PIL/TiffImagePlugin.py
Lines 2153 to 2159 in 3f24276
Pillow/src/PIL/TiffImagePlugin.py
Lines 2198 to 2200 in 3f24276
Rather than just adding in
rewriteLastLong8(),readLong8(), and adding anisLong8parameter, I've reworked the internals of the class to pass around the field size in my first commit. That made adding support for LONG8 very straightforward in my second commit.