diff --git a/cookbook/models.py b/cookbook/models.py index 0504d9dc5..16618d902 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -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) diff --git a/nginx/conf.d/Recipes.conf b/nginx/conf.d/Recipes.conf index 9e7b1283c..d87031f9b 100644 --- a/nginx/conf.d/Recipes.conf +++ b/nginx/conf.d/Recipes.conf @@ -1,6 +1,9 @@ server { listen 80; server_name localhost; + + client_max_body_size 16m; + # serve static files location /static/ { alias /static/;