Commit 4ae4d2b6 authored by Skia's avatar Skia 🤘
Browse files

Add overwrite mode and change compressed size width in picture resizing

parent f09cea40
Pipeline #544 passed with stage
in 2 minutes and 30 seconds
......@@ -44,14 +44,18 @@ class Picture(SithFile):
def get_absolute_url(self):
return reverse('sas:picture', kwargs={'picture_id': self.id})
def generate_thumbnails(self):
def generate_thumbnails(self, overwrite=False):
im = Image.open(BytesIO(self.file.read()))
try:
im = exif_auto_rotate(im)
except: pass
file = resize_image(im, max(im.size), self.mime_type.split('/')[-1])
thumb = resize_image(im, 200, self.mime_type.split('/')[-1])
compressed = resize_image(im, 600, self.mime_type.split('/')[-1])
compressed = resize_image(im, 1200, self.mime_type.split('/')[-1])
if overwrite:
self.file.delete()
self.thumbnail.delete()
self.compressed.delete()
self.file = file
self.file.name = self.name
self.thumbnail = thumb
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment