Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ run-automation:
cd recipe_automation && . venv/bin/activate && python main.py

# Image standardization target
# Usage: make standardize-image IMAGE=path/to/image.jpg [OUTPUT=path/to/output.jpg] [MAX_WIDTH=800] [MAX_HEIGHT=600] [FORMAT=JPEG] [QUALITY=85]
# Usage: make standardize-image IMAGE=path/to/image.jpg [OUTPUT=path/to/output.jpg] [MAX_WIDTH=800] [MAX_HEIGHT=600] [FORMAT=JPEG] [QUALITY=95]
standardize-image:
ifndef IMAGE
$(error IMAGE is required. Usage: make standardize-image IMAGE=path/to/image.jpg)
Expand Down
Binary file added baking/images/oatmeal-cookies-manual.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added baking/images/oatmeal-cookies.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions baking/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
## Baking Recipes

* [Banana Bread](./banana_bread.md)
* [Oatmeal Chocolate Chip Cookies](./oatmeal-chocolate-chip-cookies.md)
* [Peanut Butter Cookies](./peanutbutter-cookies)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Oatmeal Chocolate Chip Cookies

<img src="images/oatmeal-cookies-manual.jpeg" alt="Oatmeal Chocolate Chip Cookies" height="300" align="left" style="margin-right: 15px; margin-bottom: 10px;">

Crispy, salty, delicious.

**Author:** Christian Adams
Expand All @@ -10,6 +12,8 @@ Crispy, salty, delicious.

**Best Paired With:** Makes 3 dozen, 4 pans worth.

<div style="clear: both;"></div>

## Ingredients

* 1 cup / 227 grams (2 sticks) unsalted butter, softened, more for pans
Expand Down
1 change: 0 additions & 1 deletion desserts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
* [Spiced caramel pear cake](spiced-caramel-pear-cake.md)
* [Crepes](./crepes.md)
* [Pies](./pies.md)
* [Oatmeal Chocolate Chip Cookies](oatmeal-chocolate-chip-cookies.md)
12 changes: 6 additions & 6 deletions maintainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ All recipe images are automatically standardized to ensure consistency across th

| Setting | Default Value |
|---------|---------------|
| Max Width | 800px |
| Max Height | 600px |
| Max Width | 1024px |
| Max Height | 768px |
| Format | JPEG |
| Quality | 85% |
| Quality | 95% |

Images smaller than the max dimensions are not upscaled. Aspect ratio is always preserved.

Expand Down Expand Up @@ -77,10 +77,10 @@ make standardize-image IMAGE=photo.png FORMAT=WEBP QUALITY=90
|--------|-------------|---------|
| `IMAGE` | Input image path (required) | - |
| `OUTPUT` | Output path (optional, overwrites input if not set) | Same as input |
| `MAX_WIDTH` | Maximum width in pixels | 800 |
| `MAX_HEIGHT` | Maximum height in pixels | 600 |
| `MAX_WIDTH` | Maximum width in pixels | 1024 |
| `MAX_HEIGHT` | Maximum height in pixels | 768 |
| `FORMAT` | Output format (JPEG, PNG, WEBP) | JPEG |
| `QUALITY` | Quality for lossy formats (1-100) | 85 |
| `QUALITY` | Quality for lossy formats (1-100) | 95 |

### Programmatic Usage

Expand Down
28 changes: 20 additions & 8 deletions recipe_automation/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from PIL import Image

# Default settings for standardized images
DEFAULT_MAX_WIDTH = 800
DEFAULT_MAX_HEIGHT = 600
DEFAULT_MAX_WIDTH = 1024
DEFAULT_MAX_HEIGHT = 768
DEFAULT_FORMAT = "JPEG"
DEFAULT_QUALITY = 85
DEFAULT_QUALITY = 95


def standardize_image(
Expand All @@ -29,10 +29,10 @@ def standardize_image(
Args:
input_path: Path to the input image file.
output_path: Path for the output image. If None, overwrites input file.
max_width: Maximum width of the output image (default: 800).
max_height: Maximum height of the output image (default: 600).
max_width: Maximum width of the output image (default: 1024).
max_height: Maximum height of the output image (default: 768).
output_format: Output format (default: "JPEG"). Supports JPEG, PNG, WEBP.
quality: Output quality for lossy formats (1-100, default: 85).
quality: Output quality for lossy formats (1-100, default: 95).

Returns:
Path to the standardized image.
Expand All @@ -52,6 +52,10 @@ def standardize_image(

# Open and process the image
with Image.open(input_path) as img:
# Preserve EXIF and other metadata
exif_data = img.info.get("exif")
icc_profile = img.info.get("icc_profile")

# Convert to RGB if necessary (for JPEG output)
if output_format.upper() == "JPEG" and img.mode in ("RGBA", "P", "LA"):
# Create a white background for transparent images
Expand All @@ -65,7 +69,7 @@ def standardize_image(

# Calculate new dimensions maintaining aspect ratio
original_width, original_height = img.size

# Only resize if the image is larger than the max dimensions
if original_width > max_width or original_height > max_height:
# Calculate the scaling factor
Expand All @@ -84,14 +88,22 @@ def standardize_image(
if output_dir:
os.makedirs(output_dir, exist_ok=True)

# Save the image
# Save the image with preserved metadata
save_kwargs = {}
if output_format.upper() in ("JPEG", "WEBP"):
save_kwargs["quality"] = quality
save_kwargs["optimize"] = True
if output_format.upper() == "JPEG":
save_kwargs["progressive"] = True

# Preserve EXIF data if available
if exif_data:
save_kwargs["exif"] = exif_data

# Preserve ICC color profile if available
if icc_profile:
save_kwargs["icc_profile"] = icc_profile

img.save(output_path, format=output_format.upper(), **save_kwargs)

return output_path
Expand Down
2 changes: 1 addition & 1 deletion recipe_automation/processed_recipes.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"last_processed": "2025-11-29T23:33:18"}
{"last_processed": "2025-12-08T23:04:34"}
6 changes: 5 additions & 1 deletion recipe_automation/recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def create_markdown(recipe, temp_dir=None):

# Use the relative path for the markdown
image_rel_path = os.path.join("images", f"{slug}.{image_ext}")
image_ref = f"![{recipe['Recipe Name']}]({image_rel_path})\n"
image_ref = f'<img src="{image_rel_path}" alt="{recipe["Recipe Name"]}" height="300" align="left" style="margin-right: 15px; margin-bottom: 10px;">\n'

# Add the image path to the list of files to commit
if temp_dir:
Expand Down Expand Up @@ -245,6 +245,10 @@ def create_markdown(recipe, temp_dir=None):
if notes:
content += f"**Best Paired With:** {notes}\n\n"

# Clear the float before ingredients section so it appears below the image
if image_ref:
content += '<div style="clear: both;"></div>\n\n'

content += f"""## Ingredients

{ingredients}
Expand Down