Skip to content

Commit

Permalink
fixed recipe sage import and image procssing with pillow 10
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Oct 7, 2023
1 parent 2c8e029 commit 221c466
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cookbook/helper/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cookbook/integration/recipesage.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_recipe_from_file(self, file):
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
Expand All @@ -49,7 +49,7 @@ def get_recipe_from_file(self, file):
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)

Expand Down

0 comments on commit 221c466

Please sign in to comment.