Allow uncompressed TIFF images to be saved in chunks #7650
Merged
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.
Helps #4669
The issue would like to save a large TIFF image, but to do so in chunks, read then loading the entire image into memory at once.
If libtiff isn't used when saving, then the data is saved simply using the "raw" encoder.
So then what if one just appended data to a created image? The header would still need to change so that the image knew about the new size.
The image is the right size, but black.
When calculating
stride
,ifd[ROWSPERSTRIP]
andifd[STRIPBYTECOUNTS]
, TiffImagePlugin currently uses the image size. This PR updates it to useifd[IMAGEWIDTH]
andifd[IMAGELENGTH]
, and then the saved image appears correctly.Apart from this scenario,
ifd[IMAGEWIDTH]
andifd[IMAGELENGTH]
are supposed to be the same as image width and height. Two of the tests had to be updated when saving TIFF images using existing info, but I could argue that they were already incorrect in main for saving images with an incorrectifd[IMAGEWIDTH]
.