mirror of
https://github.com/pretix/pretix.git
synced 2026-05-11 16:13:59 +00:00
Apply EXIF-orientation data from source image to thumbnail with PIL.ImageOps.exif_transpose (#1869)
This commit is contained in:
committed by
GitHub
parent
a452bf816c
commit
978130551a
@@ -3,7 +3,7 @@ from io import BytesIO
|
|||||||
|
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
from django.core.files.storage import default_storage
|
from django.core.files.storage import default_storage
|
||||||
from PIL import Image
|
from PIL import Image, ImageOps
|
||||||
from PIL.Image import LANCZOS
|
from PIL.Image import LANCZOS
|
||||||
|
|
||||||
from pretix.helpers.models import Thumbnail
|
from pretix.helpers.models import Thumbnail
|
||||||
@@ -56,6 +56,9 @@ def create_thumbnail(sourcename, size):
|
|||||||
except:
|
except:
|
||||||
raise ThumbnailError('Could not load image')
|
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)
|
scale, crop = get_sizes(size, image.size)
|
||||||
image = image.resize(scale, resample=LANCZOS)
|
image = image.resize(scale, resample=LANCZOS)
|
||||||
if crop:
|
if crop:
|
||||||
|
|||||||
Reference in New Issue
Block a user