From 221c466c187c1fe95c8290689492093d2bc73677 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sat, 7 Oct 2023 08:11:50 +0200 Subject: [PATCH] fixed recipe sage import and image procssing with pillow 10 --- cookbook/helper/image_processing.py | 4 ++-- cookbook/integration/recipesage.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cookbook/helper/image_processing.py b/cookbook/helper/image_processing.py index 5fdada0c..06d022d7 100644 --- a/cookbook/helper/image_processing.py +++ b/cookbook/helper/image_processing.py @@ -10,7 +10,7 @@ def rescale_image_jpeg(image_object, base_width=1020): width_percent = (base_width / float(img.size[0])) height = int((float(img.size[1]) * float(width_percent))) - img = img.resize((base_width, height), Image.ANTIALIAS) + img = img.resize((base_width, height), Image.LANCZOS) img_bytes = BytesIO() img.save(img_bytes, 'JPEG', quality=90, optimize=True, icc_profile=icc_profile) @@ -21,7 +21,7 @@ def rescale_image_png(image_object, base_width=1020): image_object = Image.open(image_object) wpercent = (base_width / float(image_object.size[0])) hsize = int((float(image_object.size[1]) * float(wpercent))) - img = image_object.resize((base_width, hsize), Image.ANTIALIAS) + img = image_object.resize((base_width, hsize), Image.LANCZOS) im_io = BytesIO() img.save(im_io, 'PNG', quality=90) diff --git a/cookbook/integration/recipesage.py b/cookbook/integration/recipesage.py index 70b8838c..ab681c25 100644 --- a/cookbook/integration/recipesage.py +++ b/cookbook/integration/recipesage.py @@ -39,7 +39,7 @@ class RecipeSage(Integration): ingredients_added = False for s in file['recipeInstructions']: step = Step.objects.create( - instruction=s['text'], space=self.request.space, + instruction=s['text'], space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) if not ingredients_added: ingredients_added = True @@ -49,7 +49,7 @@ class RecipeSage(Integration): f = ingredient_parser.get_food(food) u = ingredient_parser.get_unit(unit) step.ingredients.add(Ingredient.objects.create( - food=f, unit=u, amount=amount, note=note, original_text=ingredient, space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, + food=f, unit=u, amount=amount, note=note, original_text=ingredient, space=self.request.space, )) recipe.steps.add(step)