Skip to content

Commit

Permalink
Merge pull request #8641 from radarhere/rawmode
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Dec 30, 2024
2 parents a4f976c + 7cee64a commit 8c3fbd5
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1559,17 +1559,6 @@ def _setup(self) -> None:
# fillorder==2 modes have a corresponding
# fillorder=1 mode
self._mode, rawmode = OPEN_INFO[key]
# libtiff always returns the bytes in native order.
# we're expecting image byte order. So, if the rawmode
# contains I;16, we need to convert from native to image
# byte order.
if rawmode == "I;16":
rawmode = "I;16N"
if ";16B" in rawmode:
rawmode = rawmode.replace(";16B", ";16N")
if ";16L" in rawmode:
rawmode = rawmode.replace(";16L", ";16N")

# YCbCr images with new jpeg compression with pixels in one plane
# unpacked straight into RGB values
if (
Expand All @@ -1578,6 +1567,14 @@ def _setup(self) -> None:
and self._planar_configuration == 1
):
rawmode = "RGB"
# libtiff always returns the bytes in native order.
# we're expecting image byte order. So, if the rawmode
# contains I;16, we need to convert from native to image
# byte order.
elif rawmode == "I;16":
rawmode = "I;16N"
elif rawmode.endswith(";16B") or rawmode.endswith(";16L"):
rawmode = rawmode[:-1] + "N"

# Offset in the tile tuple is 0, we go from 0,0 to
# w,h, and we only do this once -- eds
Expand Down

0 comments on commit 8c3fbd5

Please sign in to comment.