This commit is contained in:
j3d1 2024-01-07 16:32:58 +01:00
parent 9e1d570b07
commit 8399b7e125

View file

@ -1,4 +1,4 @@
from coverage.annotate import os
import os
from django.http import HttpResponse
from django.urls import path
from drf_yasg.utils import swagger_auto_schema
@ -40,9 +40,9 @@ def thumbnail_urls(request, hash):
hash_path = file.file
if not os.path.exists(MEDIA_ROOT + f'/thumbnails/{size}/{hash_path}'):
from PIL import Image
iamge = Image.open(file.file)
iamge.thumbnail((size, size))
rgb_image = iamge.convert('RGB')
image = Image.open(file.file)
image.thumbnail((size, size))
rgb_image = image.convert('RGB')
thumb_dir = os.path.dirname(MEDIA_ROOT + f'/thumbnails/{size}/{hash_path}')
if not os.path.exists(thumb_dir):
os.makedirs(thumb_dir)