mirror of
https://github.com/ae-utbm/sith.git
synced 2026-05-02 11:26:08 +00:00
refactor Picture.generate_thumbnails
This commit is contained in:
@@ -25,7 +25,6 @@ from django.core.files.base import ContentFile
|
||||
from django.core.files.uploadedfile import UploadedFile
|
||||
from django.http import HttpRequest
|
||||
from django.utils.timezone import localdate
|
||||
from PIL import ExifTags
|
||||
from PIL.Image import Image, Resampling
|
||||
|
||||
RED_PIXEL_PNG: Final[bytes] = (
|
||||
@@ -178,22 +177,6 @@ def resize_image_explicit(
|
||||
return ContentFile(content.getvalue())
|
||||
|
||||
|
||||
def exif_auto_rotate(image):
|
||||
for orientation in ExifTags.TAGS:
|
||||
if ExifTags.TAGS[orientation] == "Orientation":
|
||||
break
|
||||
exif = dict(image._getexif().items())
|
||||
|
||||
if exif[orientation] == 3:
|
||||
image = image.rotate(180, expand=True)
|
||||
elif exif[orientation] == 6:
|
||||
image = image.rotate(270, expand=True)
|
||||
elif exif[orientation] == 8:
|
||||
image = image.rotate(90, expand=True)
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def get_client_ip(request: HttpRequest) -> str | None:
|
||||
headers = (
|
||||
"X_FORWARDED_FOR", # Common header for proxies
|
||||
|
||||
Reference in New Issue
Block a user