From e2005fb8ef5bf311831cc489878129c6d90a4bdd Mon Sep 17 00:00:00 2001 From: Holden Date: Thu, 11 Jun 2026 23:08:37 +0000 Subject: [PATCH] fix: apply EXIF orientation when loading images from Immich PIL opens JPEGs without applying EXIF rotation. Immich computes face bounding boxes on orientation-corrected images, so portrait photos produced misaligned crops (showing chins/eyes/foreheads instead of whole faces). ImageOps.exif_transpose() normalizes orientation before any coordinate math. Co-Authored-By: Claude Sonnet 4.6 --- if_curator/immich_api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/if_curator/immich_api.py b/if_curator/immich_api.py index 8cc9756..dc8d826 100644 --- a/if_curator/immich_api.py +++ b/if_curator/immich_api.py @@ -7,7 +7,7 @@ from io import BytesIO import numpy as np import requests -from PIL import Image +from PIL import Image, ImageOps from .config import Config, get_headers @@ -168,7 +168,7 @@ def fetch_full_image(asset_id: str, timeout: int = 60) -> Image.Image | None: ) if resp.ok: try: - return Image.open(BytesIO(resp.content)) + return ImageOps.exif_transpose(Image.open(BytesIO(resp.content))) except Exception: logger.debug(f"PIL can't open original for {asset_id}, falling back to preview") except requests.RequestException: @@ -182,7 +182,7 @@ def fetch_full_image(asset_id: str, timeout: int = 60) -> Image.Image | None: timeout=30, ) if resp.ok: - return Image.open(BytesIO(resp.content)) + return ImageOps.exif_transpose(Image.open(BytesIO(resp.content))) except Exception as e: logger.error(f"Failed to fetch image {asset_id}: {e}")