Skip to content

Commit

Permalink
When TIFF applies orientation on load, delete tag
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Sep 7, 2023
1 parent dff7dcc commit 4e8c45a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Tests/test_file_libtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,10 @@ def test_orientation(self):
with Image.open("Tests/images/g4_orientation_1.tif") as base_im:
for i in range(2, 9):
with Image.open("Tests/images/g4_orientation_" + str(i) + ".tif") as im:
assert 274 in im.tag_v2

im.load()
assert 274 not in im.tag_v2

assert_image_similar(base_im, im, 0.7)

Expand Down
4 changes: 3 additions & 1 deletion src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,9 @@ def load(self):
return super().load()

def load_end(self):
ImageOps.exif_transpose(self, in_place=True)
if ExifTags.Base.Orientation in self.tag_v2:
ImageOps.exif_transpose(self, in_place=True)
del self.tag_v2[ExifTags.Base.Orientation]

# allow closing if we're on the first frame, there's no next
# This is the ImageFile.load path only, libtiff specific below.
Expand Down

0 comments on commit 4e8c45a

Please sign in to comment.