tweaked compression and upload limit

This commit is contained in:
vabene1111 2019-12-25 19:41:25 +01:00
parent 3fbd2ef032
commit 6a010587bf
2 changed files with 11 additions and 2 deletions

View File

@ -74,9 +74,15 @@ class Recipe(models.Model):
def save(self, *args, **kwargs):
if self.image:
im = Image.open(self.image)
img = Image.open(self.image)
basewidth = 720
wpercent = (basewidth / float(img.size[0]))
hsize = int((float(img.size[1]) * float(wpercent)))
img = img.resize((basewidth, hsize), Image.ANTIALIAS)
im_io = BytesIO()
im.save(im_io, 'JPEG', quality=70)
img.save(im_io, 'JPEG', quality=70)
self.image = File(im_io, name=(str(self.pk)+'.jpeg'))
super().save(*args, **kwargs)

View File

@ -1,6 +1,9 @@
server {
listen 80;
server_name localhost;
client_max_body_size 16m;
# serve static files
location /static/ {
alias /static/;