Apply EXIF-orientation data from source image to thumbnail with PIL.ImageOps.exif_transpose (#1869)

This commit is contained in:
Richard Schreiber
2020-12-03 10:55:18 +01:00
committed by GitHub
parent a452bf816c
commit 978130551a

View File

@@ -3,7 +3,7 @@ from io import BytesIO
from django.core.files.base import ContentFile
from django.core.files.storage import default_storage
from PIL import Image
from PIL import Image, ImageOps
from PIL.Image import LANCZOS
from pretix.helpers.models import Thumbnail
@@ -56,6 +56,9 @@ def create_thumbnail(sourcename, size):
except:
raise ThumbnailError('Could not load image')
# before we calc thumbnail, we need to check and apply EXIF-orientation
image = ImageOps.exif_transpose(image)
scale, crop = get_sizes(size, image.size)
image = image.resize(scale, resample=LANCZOS)
if crop: