mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 17:54:32 +03:00
Allow exif_transpose to work on Image instances as well as ImageFile
This commit is contained in:
parent
38fb9b1030
commit
8f0db65cd7
|
@ -240,14 +240,18 @@ class TestImageOps(PillowTestCase):
|
|||
for i in range(2, 9):
|
||||
im = Image.open("Tests/images/hopper_orientation_"+str(i)+ext)
|
||||
orientations.append(im)
|
||||
for im in orientations:
|
||||
if im is base_im:
|
||||
for i, orientation_im in enumerate(orientations):
|
||||
for im in [
|
||||
orientation_im, # ImageFile
|
||||
orientation_im.copy() # Image
|
||||
]:
|
||||
if i == 0:
|
||||
self.assertNotIn("exif", im.info)
|
||||
else:
|
||||
original_exif = im.info["exif"]
|
||||
transposed_im = ImageOps.exif_transpose(im)
|
||||
self.assert_image_similar(base_im, transposed_im, 17)
|
||||
if im is base_im:
|
||||
if i == 0:
|
||||
self.assertNotIn("exif", im.info)
|
||||
else:
|
||||
self.assertNotEqual(transposed_im.info["exif"], original_exif)
|
||||
|
|
|
@ -532,9 +532,9 @@ def exif_transpose(image):
|
|||
:param image: The image to transpose.
|
||||
:return: An image.
|
||||
"""
|
||||
if isinstance(image, ImageFile.ImageFile):
|
||||
exif = image.getexif()
|
||||
if exif:
|
||||
if "exif" in image.info:
|
||||
exif = ImageFile.Exif()
|
||||
exif.load(image.info["exif"])
|
||||
orientation = exif.get(0x0112)
|
||||
method = {
|
||||
2: Image.FLIP_LEFT_RIGHT,
|
||||
|
|
Loading…
Reference in New Issue
Block a user