From ea953c0514d999bd0243613bd1386f28c496b793 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 8 Sep 2023 15:05:36 +1000 Subject: [PATCH] When TIFF applies orientation on load, delete tag from getexif() --- src/PIL/TiffImagePlugin.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index 99c23ad4b28..9aab863ff22 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -1203,20 +1203,6 @@ def load(self): return super().load() def load_end(self): - if self._tile_orientation: - method = { - 2: Image.Transpose.FLIP_LEFT_RIGHT, - 3: Image.Transpose.ROTATE_180, - 4: Image.Transpose.FLIP_TOP_BOTTOM, - 5: Image.Transpose.TRANSPOSE, - 6: Image.Transpose.ROTATE_270, - 7: Image.Transpose.TRANSVERSE, - 8: Image.Transpose.ROTATE_90, - }.get(self._tile_orientation) - if method is not None: - self.im = self.im.transpose(method) - self._size = self.im.size - # allow closing if we're on the first frame, there's no next # This is the ImageFile.load path only, libtiff specific below. if not self.is_animated: @@ -1233,6 +1219,8 @@ def load_end(self): continue exif.get_ifd(key) + ImageOps.exif_transpose(self, in_place=True) + def _load_libtiff(self): """Overload method triggered when we detect a compressed tiff Calls out to libtiff""" @@ -1542,8 +1530,6 @@ def _setup(self): palette = [o8(b // 256) for b in self.tag_v2[COLORMAP]] self.palette = ImagePalette.raw("RGB;L", b"".join(palette)) - self._tile_orientation = self.tag_v2.get(ExifTags.Base.Orientation) - # # --------------------------------------------------------------------