mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-21 12:44:46 +03:00
speed improvements
This commit is contained in:
parent
7fb93f4540
commit
58a80ad3a9
|
@ -568,14 +568,14 @@ def solarize(image, threshold=128):
|
||||||
|
|
||||||
def exif_transpose(image):
|
def exif_transpose(image):
|
||||||
"""
|
"""
|
||||||
Transpose an image accordingly if it has an EXIF Orientation tag
|
Transpose a PIL image accordingly if it has an EXIF Orientation tag.
|
||||||
|
|
||||||
:param image: The image to transpose.
|
:param image: The image to transpose.
|
||||||
:return: An image.
|
:return: An image.
|
||||||
"""
|
"""
|
||||||
exif = image.getexif()
|
exif = image.getexif()
|
||||||
orientation = exif.get(0x0112)
|
orientation = exif.get(0x0112, 1) # default 1
|
||||||
if orientation is not None:
|
if orientation > 1:
|
||||||
method = {2: Image.FLIP_LEFT_RIGHT,
|
method = {2: Image.FLIP_LEFT_RIGHT,
|
||||||
3: Image.ROTATE_180,
|
3: Image.ROTATE_180,
|
||||||
4: Image.FLIP_TOP_BOTTOM,
|
4: Image.FLIP_TOP_BOTTOM,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user