better scss

This commit is contained in:
thomas girod
2024-07-26 15:14:37 +02:00
parent 594776f3a6
commit 424639ea80
10 changed files with 37 additions and 71 deletions

View File

@ -13,7 +13,6 @@
#
#
import os
from io import BytesIO
from django.conf import settings
@ -46,9 +45,7 @@ class Picture(SithFile):
@property
def is_vertical(self):
with open(
os.path.join(settings.MEDIA_ROOT, self.file.name).encode("utf-8"), "rb"
) as f:
with open(settings.MEDIA_ROOT / self.file.name, "rb") as f:
im = Image.open(BytesIO(f.read()))
(w, h) = im.size
return (w / h) < 1
@ -112,9 +109,7 @@ class Picture(SithFile):
def rotate(self, degree):
for attr in ["file", "compressed", "thumbnail"]:
name = self.__getattribute__(attr).name
with open(
os.path.join(settings.MEDIA_ROOT, name).encode("utf-8"), "r+b"
) as file:
with open(settings.MEDIA_ROOT / name, "r+b") as file:
if file:
im = Image.open(BytesIO(file.read()))
file.seek(0)