mirror of
https://github.com/ae-utbm/sith.git
synced 2026-05-03 11:56:07 +00:00
refactor Picture.generate_thumbnails
This commit is contained in:
@@ -622,8 +622,7 @@ class Command(BaseCommand):
|
||||
)
|
||||
pict.file.name = p.name
|
||||
pict.full_clean()
|
||||
pict.generate_thumbnails()
|
||||
pict.save()
|
||||
pict.generate_thumbnails(save=True)
|
||||
|
||||
img_skia = Picture.objects.get(name="skia.jpg")
|
||||
img_sli = Picture.objects.get(name="sli.jpg")
|
||||
|
||||
@@ -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