Refactor logging and improve image optimization in RecipeRoutes and ExifUtils

- Removed print statements for initialization and setup in RecipeRoutes to reduce console clutter and improve logging practices.
- Updated image optimization parameters in RecipeRoutes to enhance image quality by increasing the target width.
- Modified user comment handling in ExifUtils to ensure proper formatting when appending recipe metadata, improving metadata consistency.
This commit is contained in:
Will Miao
2025-03-19 14:50:36 +08:00
parent c3aaef3916
commit f9c54690b0
2 changed files with 6 additions and 16 deletions

View File

@@ -135,7 +135,7 @@ class ExifUtils:
recipe_metadata_marker = f"Recipe metadata: {recipe_metadata_json}"
# Append to existing user comment or create new one
new_user_comment = user_comment + "\n" + recipe_metadata_marker if user_comment else recipe_metadata_marker
new_user_comment = f"{user_comment}, {recipe_metadata_marker}" if user_comment else recipe_metadata_marker
# Write back to the image
return ExifUtils.update_user_comment(image_path, new_user_comment)
@@ -154,6 +154,10 @@ class ExifUtils:
if recipe_marker_index == -1:
return user_comment
# If recipe metadata is not at the start, remove the preceding ", "
if recipe_marker_index >= 2 and user_comment[recipe_marker_index-2:recipe_marker_index] == ", ":
recipe_marker_index -= 2
# Remove the recipe metadata part
# First, find where the metadata ends (next line or end of string)
next_line_index = user_comment.find("\n", recipe_marker_index)