From 978130551a7dd5219ef3037bdb95b1d846b74757 Mon Sep 17 00:00:00 2001 From: Richard Schreiber Date: Thu, 3 Dec 2020 10:55:18 +0100 Subject: [PATCH] Apply EXIF-orientation data from source image to thumbnail with PIL.ImageOps.exif_transpose (#1869) --- src/pretix/helpers/thumb.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pretix/helpers/thumb.py b/src/pretix/helpers/thumb.py index de0ba9bb3..aa72e9e48 100644 --- a/src/pretix/helpers/thumb.py +++ b/src/pretix/helpers/thumb.py @@ -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: