Limit TIFF strip size when saving with LibTIFF#5514
Merged
hugovk merged 5 commits intopython-pillow:masterfrom Jun 30, 2021
Merged
Limit TIFF strip size when saving with LibTIFF#5514hugovk merged 5 commits intopython-pillow:masterfrom
hugovk merged 5 commits intopython-pillow:masterfrom
Conversation
Contributor
Author
|
Ah, in the process a new bug was uncovered - the updated test sequence with grayscale conversion: info = im.tag_v2
# Resize the image so that STRIPBYTECOUNTS will be larger than a SHORT (64 KB exactly)
im = im.convert("L").resize((512, 512))
# STRIPBYTECOUNTS can be a SHORT or a LONG
info.tagtype[TiffImagePlugin.STRIPBYTECOUNTS] = TiffTags.SHORT
im.save(out, tiffinfo=info)produces an invalid TIFF where some of the original tag values are not overwritten: |
Contributor
Author
|
Still work to do: StripOffsets and StripByteCounts are assumed to be just single values instead of being derived and stored as arrays if multiple strips are present. |
820997e to
4b5488c
Compare
Contributor
Author
|
Changed to only fix compressed saving (or when libtiff writer is forced), as those cannot be read otherwise. Uncompressed internal writer still uses a single strip (updating the strip offsets still TODO), as those files can be read when #5517 is merged (but also only if libtiff reader is forced). |
03e4d2e to
8b82986
Compare
8b82986 to
100299a
Compare
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.
Addresses #5370 partly.
Doesn't really "fix" the loading of any existing >2GB single strip images (would need to handle specially by buffered read in decoder), but reduces their incidence as recommended by the TIFF spec.