Fix saving MPO with more than one appended image #8979
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.
Resolves #8977
With each new frame that is saved to an MPO image, an offset is added
Pillow/src/PIL/MpoImagePlugin.py
Lines 65 to 68 in 086e05f
leading to a longer
mpentriesPillow/src/PIL/MpoImagePlugin.py
Line 81 in 086e05f
meaning the IFD becomes longer
Pillow/src/PIL/MpoImagePlugin.py
Line 85 in 086e05f
We rewind and replace the placeholder data with the IFD
Pillow/src/PIL/MpoImagePlugin.py
Lines 87 to 89 in 086e05f
But the placeholder data only ever has the same number of bytes, regardless of the number of frames.
Pillow/src/PIL/MpoImagePlugin.py
Line 55 in 086e05f
This PR increases the length of the placeholder data as the number of frames increase.