When orientation is applied, delete TIFF tag

This commit is contained in:
Andrew Murray 2023-09-08 14:09:47 +10:00
parent e195e60ce2
commit d0abab7997
2 changed files with 7 additions and 0 deletions

View File

@ -1035,7 +1035,10 @@ class TestFileLibTiff(LibTiffTestCase):
with Image.open("Tests/images/g4_orientation_1.tif") as base_im: with Image.open("Tests/images/g4_orientation_1.tif") as base_im:
for i in range(2, 9): for i in range(2, 9):
with Image.open("Tests/images/g4_orientation_" + str(i) + ".tif") as im: with Image.open("Tests/images/g4_orientation_" + str(i) + ".tif") as im:
assert 274 in im.tag_v2
im.load() im.load()
assert 274 not in im.tag_v2
assert_image_similar(base_im, im, 0.7) assert_image_similar(base_im, im, 0.7)

View File

@ -611,6 +611,10 @@ def exif_transpose(image, *, in_place=False):
exif = exif_image.getexif() exif = exif_image.getexif()
if ExifTags.Base.Orientation in exif: if ExifTags.Base.Orientation in exif:
del exif[ExifTags.Base.Orientation] del exif[ExifTags.Base.Orientation]
if in_place and ExifTags.Base.Orientation in getattr(
exif_image, "tag_v2", {}
):
del exif_image.tag_v2[ExifTags.Base.Orientation]
if "exif" in exif_image.info: if "exif" in exif_image.info:
exif_image.info["exif"] = exif.tobytes() exif_image.info["exif"] = exif.tobytes()
elif "Raw profile type exif" in exif_image.info: elif "Raw profile type exif" in exif_image.info: