Repository navigation
Fix BigTIFF strip offsets that fit within the entry - #10260
Merged
radarhere merged 2 commits intoOct 21, 2026
Merged
Conversation
radarhere
force-pushed
the
fix-bigtiff-inline-strip-offsets
branch
from
October 21, 2026 00:52
1c0edc3 to
d8bc325
Compare
radarhere
force-pushed
the
fix-bigtiff-inline-strip-offsets
branch
from
October 21, 2026 01:08
d8bc325 to
633b15f
Compare
radarhere
enabled auto-merge (squash)
October 21, 2026 01:09
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.
Changes proposed in this pull request:
ImageFileDirectory_v2.tobytes()adds the data offset to the StripOffsets values. If the values fit within the entry, it did this by unpacking the whole entry as one integer of the offset size (L, orQfor BigTIFF), adding the offset and packing it again. StripOffsets is written as LONG, so in an 8-byte BigTIFF entry:test_bigtiff_save_two_stripssaveshopper("L")as BigTIFF withRowsPerStrip64, so there are two strips, and checks that it reads back equal.test_bigtiff_save_big_endian_strip_offsetsaveshopper("I;16B")as BigTIFF and checks that it reads back equal. It also checks that the strip offset is written as LONG8 when the IFD is written at an offset of 2**32.Testing:
main, both new tests fail withFailed: got different content, and both pass with this change. Without the LONG8 upgrade,test_bigtiff_save_big_endian_strip_offsetand the existingtest_bigtiff_save_big_endian_ifdfail withstruct.error: 'L' format requires 0 <= number <= 4294967295.tiffdump:big_tiff=True, tiffinfo={278: 150}givesStripOffsets (273) LONG (4) 2<212 45000>onmainand2<212 45212>with this change.1<0>onmainand1<212>with this change.tiffcpcopies of both files have the same pixels as the source.python3 selftest.pypasses.python3 -m pytest Tests -n 6on macOS arm64 gives 5391 passed, 365 skipped, 3 xfailed.ruff check(0.16.10) andblack --check(26.10.0) on the changed files pass.mypyand the fullpre-commit run --all-fileswere not run.struct.errorwhen there is more than one strip, as they already did onmainonce the values are stored outside the entry. Two such offsets within the entry were silently written wrong before, and now raise the same error.