@@ -1559,17 +1559,6 @@ def _setup(self) -> None:
15591559 # fillorder==2 modes have a corresponding
15601560 # fillorder=1 mode
15611561 self ._mode , rawmode = OPEN_INFO [key ]
1562- # libtiff always returns the bytes in native order.
1563- # we're expecting image byte order. So, if the rawmode
1564- # contains I;16, we need to convert from native to image
1565- # byte order.
1566- if rawmode == "I;16" :
1567- rawmode = "I;16N"
1568- if ";16B" in rawmode :
1569- rawmode = rawmode .replace (";16B" , ";16N" )
1570- if ";16L" in rawmode :
1571- rawmode = rawmode .replace (";16L" , ";16N" )
1572-
15731562 # YCbCr images with new jpeg compression with pixels in one plane
15741563 # unpacked straight into RGB values
15751564 if (
@@ -1578,6 +1567,14 @@ def _setup(self) -> None:
15781567 and self ._planar_configuration == 1
15791568 ):
15801569 rawmode = "RGB"
1570+ # libtiff always returns the bytes in native order.
1571+ # we're expecting image byte order. So, if the rawmode
1572+ # contains I;16, we need to convert from native to image
1573+ # byte order.
1574+ elif rawmode == "I;16" :
1575+ rawmode = "I;16N"
1576+ elif rawmode .endswith (";16B" ) or rawmode .endswith (";16L" ):
1577+ rawmode = rawmode [:- 1 ] + "N"
15811578
15821579 # Offset in the tile tuple is 0, we go from 0,0 to
15831580 # w,h, and we only do this once -- eds
0 commit comments