mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
better scss
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user