|
252 | 252 | (II, 3, (1,), 1, (8,), ()): ("P", "P"),
|
253 | 253 | (MM, 3, (1,), 1, (8,), ()): ("P", "P"),
|
254 | 254 | (II, 3, (1,), 1, (8, 8), (0,)): ("P", "PX"),
|
| 255 | + (MM, 3, (1,), 1, (8, 8), (0,)): ("P", "PX"), |
255 | 256 | (II, 3, (1,), 1, (8, 8), (2,)): ("PA", "PA"),
|
256 | 257 | (MM, 3, (1,), 1, (8, 8), (2,)): ("PA", "PA"),
|
257 | 258 | (II, 3, (1,), 2, (8,), ()): ("P", "P;R"),
|
@@ -1177,6 +1178,7 @@ def _open(self) -> None:
|
1177 | 1178 | """Open the first image in a TIFF file"""
|
1178 | 1179 |
|
1179 | 1180 | # Header
|
| 1181 | + assert self.fp is not None |
1180 | 1182 | ifh = self.fp.read(8)
|
1181 | 1183 | if ifh[2] == 43:
|
1182 | 1184 | ifh += self.fp.read(8)
|
@@ -1343,6 +1345,7 @@ def _load_libtiff(self) -> Image.core.PixelAccess | None:
|
1343 | 1345 | # To be nice on memory footprint, if there's a
|
1344 | 1346 | # file descriptor, use that instead of reading
|
1345 | 1347 | # into a string in python.
|
| 1348 | + assert self.fp is not None |
1346 | 1349 | try:
|
1347 | 1350 | fp = hasattr(self.fp, "fileno") and self.fp.fileno()
|
1348 | 1351 | # flush the file descriptor, prevents error on pypy 2.4+
|
@@ -1936,9 +1939,10 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
1936 | 1939 | types[tag] = TiffTags.LONG8
|
1937 | 1940 | elif tag in ifd.tagtype:
|
1938 | 1941 | types[tag] = ifd.tagtype[tag]
|
1939 |
| - elif not (isinstance(value, (int, float, str, bytes))): |
1940 |
| - continue |
1941 |
| - else: |
| 1942 | + elif isinstance(value, (int, float, str, bytes)) or ( |
| 1943 | + isinstance(value, tuple) |
| 1944 | + and all(isinstance(v, (int, float, IFDRational)) for v in value) |
| 1945 | + ): |
1942 | 1946 | type = TiffTags.lookup(tag).type
|
1943 | 1947 | if type:
|
1944 | 1948 | types[tag] = type
|
|
0 commit comments